How to read from detected NFC tag (NDEF message). Android NFC

混江龙づ霸主 提交于 2019-12-04 14:52:54

Try this Snippet to extract message from Tag :

Parcelable[] rawMsgs = intent
            .getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
    NdefMessage msg = (NdefMessage) rawMsgs[0];
    extractMessage(msg);

private void extractMessage(NdefMessage msg) {
        byte[] array = null;
        array = msg.getRecords()[0].getPayload();
}

Also Check out this Sample for NFC Reader/Writer

To get the intent that passes the NFC tag to start the activity in my case "nfcintent" just use

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