简体   繁体   中英

Android NDEF NFC Payload

I am using NDEF nfc cards and my application is reading the data in the card. Everything works great. However as part of the payload I am also getting the language type in it.

If the NFC string is "Hello"

String text = new String(records.get(k).getNdefRecord().getPayload());

Output is "enHello"

I am sure I can use substring to remove the first two characters but is there a way to get Payload message only without getting the language string in it?

Any help will be very appreciated. Thank you in advance!!

What's your strategy for converting from a byte array to a String? There's more data returned in getPayload() than simply the text you want to read. This link has a breakdown of the protocol, plus there's another link or two on SO like this one that explains how to handle it.

I've implemented a library called NDEF Tools for Android for reading and writing high-level record representation from the basic NdefMessage/NdefRecord in Android. See the Text Record for some pointers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM