我有一个处理RFID卡的项目,在RF Reader上点击卡之后,它会记录数据并需要再次运行RFCard Reader。但是我的问题是我点击了卡之后,由于CallBack();
不再运行,因此无法读取下一张将被点击的卡。
我尝试过此操作,在3-5次之后,阅读器停止了。
class myCallbackThread extends Thread{
@Override
public void run(){
try{
//my code of saving will be here...
myCallbackThread myCallbackThread = new myCallbackThread();
myCallbackThread.start();
}catch (Throwable e){
e.printStackTrace();
}
}
}
It完整的代码是CallBack();
函数。我的问题是成功执行后如何再次调用它以重复该过程?
class CallBackThread extends Thread {
@Override
public void run() {
try {
RFCardInterface.waitForCardPresent(RFCardInterface.CONTACTLESS_CARD_MODE_AUTO, 1, -1);
if (RFCardInterface.isCallBackCalled &&
RFCardInterface.notifyEvent.eventID == RFCardInterface.CONTACTLESS_CARD_EVENT_FOUND_CARD) {
IDCatcher = StringUtility.ByteArrayToString(RFCardInterface.notifyEvent.eventData,
RFCardInterface.notifyEvent.eventData.length);
IDCatcher = IDCatcher.substring(9, 21).replace(" ", "");
Log.e("IDCatcher", IDCatcher);
EventBus.getDefault().post(new EBTest2());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
如何实现使其不确定?谢谢
编辑,添加了我的EBtest2()
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
public void onEvent(EBTest2 ebTest2) {
Cursor c = dbhelper.getReadableDatabase().rawQuery("select is_arrived,is_closed from trans_settings order by _id desc limit 1", null);
if (c != null && c.moveToFirst()) {
try {
String is_arrived = c.getString(0);
String is_closed = c.getString(1);
if (is_arrived.equals("0") && is_closed.equals("0")) {
SearchEmp();
} else if (is_arrived.equals("1") && is_closed.equals("0")) {
SearchEmp_isArrived();
} else if (is_arrived.equals("1") && is_closed.equals("1")) {
SearchEmp_isClosed();
}
} catch (Throwable e) {
e.printStackTrace();
}
c.close();
}
}