Code example for NdefMessage

Methods: toByteArray

0
 
		NdefRecord record = new NdefRecord(
				NdefRecord.TNF_MIME_MEDIA, "text/plain".getBytes()
				,new byte[]{} 
				, bytes);
		return new NdefMessage(new NdefRecord[]{record});
	} 
 
	public static String writeMessage(String msg, Intent intent) {
		Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
		return write(toNdefMessage(msg), tag);
	} 
 
	public static String write(NdefMessage msg, Tag tag) {
		try { 
			Ndef ndef = Ndef.get(tag);
				if (ndef != null) {
					ndef.connect();
 
					if (!ndef.isWritable()) {
						return WRITE_READ_ONLY;
					} 
					if (ndef.getMaxSize() < msg.toByteArray().length) {
						return WRITE_MAX_SIZE;
					} 
					ndef.writeNdefMessage(msg);
					return WRITE_OK;
				} else { 
Stop searching for code, let great code find you!  Add Codota to your java IDE