Android examples for Network:NFC Message
strings To NFC Ndef Message
//package com.java2s; import android.nfc.NdefMessage; import android.nfc.NdefRecord; import java.util.ArrayList; public class Main { public static NdefMessage stringsToNdefMessage(String... strings) { ArrayList<NdefRecord> ndefRecords = new ArrayList<NdefRecord>(); for (String string : strings) { byte[] textBytes = string.getBytes(); NdefRecord textRecord = new NdefRecord( NdefRecord.TNF_MIME_MEDIA, "text/plain".getBytes(), new byte[] {}, textBytes); ndefRecords.add(textRecord); }//from w w w .jav a2 s . c o m ndefRecords.add(NdefRecord .createApplicationRecord("com.unlock.gate")); NdefRecord[] records = new NdefRecord[ndefRecords.size()]; ndefRecords.toArray(records); return new NdefMessage(records); } }