0
votes

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!!

2

2 Answers

0
votes

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.

0
votes

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.