create Text NFC Record - Android Network

Android examples for Network:NFC Record

Description

create Text NFC Record

Demo Code


//package com.java2s;

import java.nio.charset.Charset;

import android.nfc.NdefRecord;

public class Main {

    public static NdefRecord createTextRecord(String payload) {
 
        Charset utfEncoding = Charset.forName("UTF-8");
        byte[] textBytes = payload.getBytes(utfEncoding);
        NdefRecord ndefRecord = null;//from www. j  a va2  s .  c o  m

        ndefRecord = new NdefRecord(NdefRecord.TNF_WELL_KNOWN,
                NdefRecord.RTD_TEXT, new byte[0], textBytes);
        return ndefRecord;
    }
}

Related Tutorials