get NFC Ndef Messages from Parcelable - Android Network

Android examples for Network:NFC Message

Description

get NFC Ndef Messages from Parcelable

Demo Code


//package com.java2s;

import android.nfc.NdefMessage;

import android.os.Parcelable;

public class Main {
    public static NdefMessage[] getNdefMessages(Parcelable[] rawMsgs) {
        // Parse the intent
        NdefMessage[] msgs = null;/* ww w.ja va  2  s  .  com*/
        if (rawMsgs != null) {
            msgs = new NdefMessage[rawMsgs.length];
            for (int i = 0; i < rawMsgs.length; i++) {
                msgs[i] = (NdefMessage) rawMsgs[i];
            }
        } else {
            // Unknown tag type
            msgs = new NdefMessage[0];
        }
        return msgs;
    }
}

Related Tutorials