|
发表于 2020-10-13 11:09:41
只看该作者
沙发
1、您好,请确认是否已执行IDCardUtil.startIDCardListener();
[size=13.0667px]可以参考Demo中的IDCardTestActivity
[size=13.0667px]
@Override
protected void onResume() {
super.onResume()
IDCardUtil.getInstance().startIDCardListener(IDCardTestActivity.this,callBack);
}
@Override
protected void onPause() {
super.onPause();
IDCardUtil.getInstance().stopIDCardListener(IDCardTestActivity.this);
}
2、另外IDCardUtil.startIDCardListener();主要是执行如下代码:
public void startIDCardListener(Context context, IDCardUtil.IDCardCallBack callback) {
this.bindIDCardService(context);
this.setIDCardCallBack(callback);
}
public void stopIDCardListener(Context context) {
this.unBindIDCardService(context);
this.setIDCardCallBack((IDCardUtil.IDCardCallBack)null);
}
private void bindIDCardService(Context mContext) {
try {
if (!this.isRegisterService) {
Intent intent = new Intent("com.firefly.IDCardService");
intent.setPackage("com.firefly.id_card");
boolean ret = mContext.bindService(intent, this.mServiceConnection, 1);
Log.v("idcarddemo", "bindService:" + ret);
this.isRegisterService = true;
}
} catch (Exception var4) {
var4.printStackTrace();
}
}
private void unBindIDCardService(Context mContext) {
try {
if (this.isRegisterService) {
if (this.mService != null) {
this.mService.unregisterCallback(this.mCallback);
}
mContext.unbindService(this.mServiceConnection);
this.isRegisterService = false;
}
} catch (Exception var3) {
var3.printStackTrace();
}
}
[size=13.0667px]
|
|