взял код для чтения RFID меток с хабры, код запустил на физическом устройте, теперь у меня проблема, как сделать так, что бы программа выводила считанные данные метки на экран.
Непосредственно сам код:
Код: Выделить всё
private void processIntent(Intent intent) {
Tag tagFromIntent = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
for (String tech : tagFromIntent.getTechList()) {
System.out.println(tech);
}
boolean auth = false;
MifareClassic mfc = MifareClassic.get(tagFromIntent);
try {
String metaInfo = "";
//Enable I/O operations to the tag from this TagTechnology object.
mfc.connect();
int type = mfc.getType();
int sectorCount = mfc.getSectorCount();
String typeS = "";
switch (type) {
case MifareClassic.TYPE_CLASSIC:
typeS = "TYPE_CLASSIC";
break;
case MifareClassic.TYPE_PLUS:
typeS = "TYPE_PLUS";
break;
case MifareClassic.TYPE_PRO:
typeS = "TYPE_PRO";
break;
case MifareClassic.TYPE_UNKNOWN:
typeS = "TYPE_UNKNOWN";
break;
}
metaInfo += "Card type:" + typeS + "n with" + sectorCount + " Sectorsn, "
+ mfc.getBlockCount() + " BlocksnStorage Space: " + mfc.getSize() + "Bn";
for (int j = 0; j < sectorCount; j++) {
//Authenticate a sector with key A.
auth = mfc.authenticateSectorWithKeyA(j,
MifareClassic.KEY_DEFAULT);
int bCount;
int bIndex;
if (auth) {
metaInfo += "Sector " + j + ": Verified successfullyn";
bCount = mfc.getBlockCountInSector(j);
bIndex = mfc.sectorToBlock(j);
for (int i = 0; i < bCount; i++) {
byte[] data = mfc.readBlock(bIndex);
metaInfo += "Block " + bIndex + " : "
+ bytesToHexString(data) + "n";
bIndex++;
}
} else {
metaInfo += "Sector " + j + ": Verified failuren";
}
}
promt.setText(metaInfo);
} catch (Exception e) {
e.printStackTrace();
}
}