Code example for NdefRecord

0
         
        byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8"));
        byte[] dataBytes = data.getBytes(Charset.forName("UTF-8"));
        byte[] id = new byte[0];
         
        NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, id, dataBytes);
         
        /** 
         * The Android Application Record (AAR) is commented out. When a device 
         * receives a push with an AAR in it, the application specified in the AAR 
         * is guaranteed to run. The AAR overrides the tag dispatch system. 
         * You can add it back in to guarantee that this 
         * activity starts when receiving a beamed message. For now, this code 
         * uses the tag dispatch system. 
         */ 
         //,NdefRecord.createApplicationRecord("com.example.android.beam")         
         
        NdefMessage message = new NdefMessage(new NdefRecord[] { record });
 
        // return the NDEF message