Code example for NdefRecord

0
	}; 
	 
	private NdefMessage createNDFMsg(boolean now) {
		String text = "Beam "+(now ? "NOW" : "ON")+" com.oreilly.demo.android.pa.sensordemo  Beam with" + (AARUSE ? "" : "out") + " AAR Use";
		 byte[] mimeBytes =  "application/com.oreilly.demo.android.pa.sensordemo".getBytes(Charset.forName("US-ASCII"));
		 NdefRecord mimeRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], text.getBytes());
		  
		 NdefMessage msg = new NdefMessage(new NdefRecord[] {mimeRecord});
		  
		 NdefMessage msgWaAAR = new NdefMessage(new NdefRecord[] {mimeRecord,
				 NdefRecord.createApplicationRecord("com.oreilly.demo.android.pa.sensordemo")});		
		  
		return AARUSE ? msgWaAAR : msg;
	} 
	  
	@Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nfc40);
 
        setTitle("Near Field Communication - 4.0");