[android-developers] Re: How to exract payload from NDEF message
I have added the bolded code, but getting en in front of the string:
Hi in the Boilerplate example the NfcReaderActivity has the following method:
private void showList() {
if(messages != null && messages.length > 0) {
// display the first message
byte[] messagePayload = messages[0].toByteArray();
byte[] textPayload = messages[0].getRecords()[0].getPayload();
String id = new String(textPayload);
Toast.makeText(getApplicationContext(), id, Toast.LENGTH_LONG).show();
// Output: en1
// How to get rid of en?
--
// parse to records
NdefMessageDecoder ndefMessageDecoder = NdefContext.getNdefMessageDecoder();
List<Record> records = ndefMessageDecoder.decodeToRecords( messagePayload);
// show in gui
ArrayAdapter<? extends Object> adapter = new NdefRecordAdapter(this, records);
ListView listView = (ListView) findViewById(R.id.recordListView);
listView.setAdapter(adapter);
} else {
clearList();
}
}
How could I extract the payload and use it to pass to different activity? E.g. if I had a simple integer in the payload.
Thanks heaps for your help!!!
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home