Hi,
so this example might not be totally clear, but what is happening is that
the byte[] seen as 'messagePayload' is actually the whole message and it is
feed into another tools which parses the records to high-level
representation. If you had a simple integer payload, you would for example
put that in a MimeRecord. Then there would be a MimeRecord somewhere in the
List<Array> seen below as 'records'.
So try something like
for(Record record : records) {
if(record instanceof MimeRecord) {
MimeRecord mimeRecord = (MimeRecord)record;
// get the payload
byte[] mimeRecordData = mimeRecord.getContentAsBytes();
// decode, pass data to other activities etc
}
}
Note that I've just created a NDEF spinoff of the NFC Tools for Java at:
http://code.google.com/p/ndef-tools-for-android/
which is more in line with Android.
Best regards,
Thomas
On Saturday, September 15, 2012 1:27:01 AM UTC+2, solnichko wrote:
>
> 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();
>
> // 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en