Reading the tag UID of Mifare classic card

无人久伴 提交于 2019-12-04 16:08:27

If the error is about "I am getting error of resource lookup", is not NFC related.

With this code you're getting the UID of the Tag correctly

.
.
.
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
Log.d(TAG, "UID: " + bin2hex(tag.getId()));
.
.
.
//To display the UID
static String bin2hex(byte[] data) {
    return String.format("%0" + (data.length * 2) + "X", new BigInteger(1,data));
}

If you are simulating a tag detection from your activity 1, then add the appropriate extras. Else let the android nfc service generate the intent for TECH_DISCOVERED, when it detects the actual tag.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!