友我科技IC卡读卡器Android开发应用实例


此实例将手动点击按钮读写15693卡的卡号和内容。

读写IC卡内容

代码如下:

public class ISO15693Card extends Activity
{ private TextView txtCardNo;
private EditText edtBlockID;
private EditText edtData;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_iso15693card);
txtCardNo = (TextView) findViewById(R.id.txtcardUID); edtBlockID = (EditText) findViewById(R.id.edtblockiso15693);
edtBlockID.setText("1");

edtData = (EditText) findViewById(R.id.edtdataiso15693);
edtData.setText("11223344");

Button button = (Button) findViewById(R.id.btnreadCardiso15693);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
txtCardNo.setText("");
edtData.setText("");

byte BlockID = (byte)MainActivity.ValidInt( edtBlockID.getText().toString() , 63);
if(BlockID<0)
{
MainActivity.dialog("块号必须是0-63",ISO15693Card.this);
return;
}

byte[] UID= MainActivity.rfidreader.ISO15693.YW_ISO15693_Inventory();
if(UID==null)return;
txtCardNo.setText(MainActivity.bytesToHexString(UID));
MainActivity.rfidreader.ISO15693.YW_ISO15693_Select(MainActivity.rfidreader.ISO15693.MODE_SELECT, UID);
byte[] BlockData=MainActivity.rfidreader.ISO15693.YW_ISO15693_Read(BlockID, (byte)1);
if(BlockData==null)
{
MainActivity.dialog("读卡内容失败", ISO15693Card.this);
return;
}
edtData.setText(MainActivity.bytesToHexString(BlockData));
MainActivity.rfidreader.ReaderHardware.YW_Buzzer(5, 5, 1);
}
});

Button button2 = (Button) findViewById(R.id.btnwritedataiso15693);
button2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
txtCardNo.setText("");

byte BlockID = (byte)MainActivity.ValidInt( edtBlockID.getText().toString() , 63);
if(BlockID<0)
{
MainActivity.dialog("块号必须是0-63",ISO15693Card.this);
return;
}

if(!MainActivity.ValidHexString(edtData.getText().toString(), 4))
{
MainActivity.dialog("数据必须是4字节16进制",ISO15693Card.this);
return;
}

byte[] UID= MainActivity.rfidreader.ISO15693.YW_ISO15693_Inventory();
if(UID==null)return;
txtCardNo.setText(MainActivity.bytesToHexString(UID));
MainActivity.rfidreader.ISO15693.YW_ISO15693_Select(MainActivity.rfidreader.ISO15693.MODE_SELECT, UID);

byte[] Data = MainActivity.HexStringtoBytes(edtData.getText().toString());

if(MainActivity.rfidreader.ISO15693.YW_ISO15693_Write(BlockID, Data)>0)
{
MainActivity.dialog("数据写入成功",ISO15693Card.this);
MainActivity.rfidreader.ReaderHardware.YW_Buzzer(5, 5, 1);
}
else
MainActivity.dialog("数据写入失败",ISO15693Card.this);
}
});
}
}

RFID读写器,SDK,IC卡读卡器,开发包,二次开发,智能卡读卡器,RFID读卡器,CPU卡读写器,读卡模块
北京友我科技有限公司 版权所有 (C)2015-2015
客户服务中心信箱:coodor#126.com(将#改为@).客户服务MSN: coodor#126.com(将#改为@)
热线直拨: 010-57049038 18910685939 QQ: 896163157,1403463073
京ICP备14016005号
微信扫一扫联系我们

微信扫一扫联系我们

友我科技


1
RFID读写器产品手册下载
2
读写器开发SDK下载
3
WEB读卡器开发指南
4
Windows读卡器开发指南
5
Android读卡器开发指南
6
Wince读卡器开发指南
7
PLC读卡器开发指南
8
Linux读卡器开发指南
9
单片机读卡器开发指南
10
PCSC读卡器开发指南