Code example for NdefMessage

Methods: getRecords

0
            finish();
        } 
 
        NdefMessage msg = (NdefMessage) intent.getParcelableArrayExtra(
                NfcAdapter.EXTRA_NDEF_MESSAGES)[0];
        NdefRecord records[] = msg.getRecords();
        if (records == null || records.length == 0) {
            Log.w(TAG, "No records " + intent);
            finish();
        } 
 
        NdefRecord record = records[0];
        String type = new String(record.getType(), Charset.forName("UTF8"));
        if (record.getTnf() != NdefRecord.TNF_MIME_MEDIA ||
                (!"text/x-vcard".equalsIgnoreCase(type) && !"text/vcard".equals(type))) {
            Log.w(TAG, "Not a vcard");
            //setStatus(getString(R.string.fail_reason_not_supported)); 
            return; 
        } 
        mRecord = record;