Reputation: 2209
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!!
Upvotes: 0
Views: 1623
Reputation: 8287
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.
Upvotes: 0
Reputation: 5022
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.
Upvotes: 0