Code example for NdefMessage

Methods: getRecords

0
        NdefMessage msg = (NdefMessage) rawMsgs[0];
        if(msg == null) {
            Log.d(TAG, "ndef message is null");
            return null; 
        } 
        NdefRecord[] ndefRecords = msg.getRecords();
        if(ndefRecords == null) {
            Log.d(TAG, "ndefRecords is null");
            return null; 
        } else if(ndefRecords.length < 1) {
            Log.d(TAG, "ndefRecords length is 0");
            return null; 
        } 
        NdefRecord firstNdefRecord = ndefRecords[0];
        if(firstNdefRecord == null) {
            Log.d(TAG, "firstNdefRecord is null");
            return null; 
        } 
        return firstNdefRecord.getPayload();
    } 
}