此实例将采用线程自动读取IC卡的卡号,并将卡号输出到指定位置。
代码如下:
public class AutoReadCard extends Activity {
private TextView tv;
private int offset;
private boolean bStop;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_autoreadcard);
bStop =false;
tv = (TextView) findViewById(R.id.txtcard);
tv.setMovementMethod(ScrollingMovementMethod.getInstance());
Thread thread=new Thread(new Runnable()
{
byte[] CardNo;
@Override
public void run()
{
while(!bStop)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if( MainActivity.rfidreader.ISO14443A.YW_RequestCard(MainActivity.rfidreader.ISO14443A.REQUESTMODE_ACTIVE)<0)continue;
CardNo=MainActivity.rfidreader.ISO14443A.YW_AntiCollideAndSelect(MainActivity.rfidreader.ISO14443A.MULTIMODE_ONE);
if(CardNo==null)continue;
runOnUiThread(new Runnable()
{
@Override
public void run()
{
tv.append(MainActivity.bytesToHexString(CardNo) + "\n");
offset=tv.getLineCount()*tv.getLineHeight();
if(offset>tv.getHeight())tv.scrollTo(0,offset-tv.getHeight());
}
});
MainActivity.rfidreader.ISO14443A.YW_CardHalt();
MainActivity.rfidreader.ReaderHardware.YW_Buzzer(5, 5, 1);
}
}
});
thread.start();
}
@Override
protected void onDestroy() {
bStop=true;
super.onDestroy();
};
}
RFID读写器,SDK,IC卡读卡器,开发包,二次开发,智能卡读卡器,RFID读卡器,CPU卡读写器,读卡模块 微信扫一扫联系我们 |
1 |
RFID读写器产品手册下载 |
2 |
读写器开发SDK下载 |
3 |
WEB读卡器开发指南 |
4 |
Windows读卡器开发指南 |
5 |
Android读卡器开发指南 |
6 |
Wince读卡器开发指南 |
7 |
PLC读卡器开发指南 |
8 |
Linux读卡器开发指南 |
9 |
单片机读卡器开发指南 |
10 |
PCSC读卡器开发指南 |