Code example for NdefRecord

0
        byte[] mimeBytes = "application/com.android.cts.verifier.nfc"
                .getBytes(Charset.forName("US-ASCII"));
        byte[] id = new byte[] {1, 3, 3, 7};
        byte[] payload = "CTS Verifier NDEF Push Tag".getBytes(Charset.forName("US-ASCII"));
        return new NdefMessage(new NdefRecord[] {
                new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, id, payload)
        }); 
    } 
 
    @Override 
    protected void onResume() { 
        super.onResume(); 
        mNfcAdapter.enableForegroundNdefPush(this, TEST_MESSAGE);
    } 
 
    @Override 
    protected void onPause() { 
        super.onPause(); 
        mNfcAdapter.disableForegroundNdefPush(this);
    }