Create URI record - Android Network

Android examples for Network:Uri

Description

Create URI record

Demo Code


//package com.java2s;

import java.nio.charset.Charset;

import android.nfc.NdefRecord;

public class Main {

    public static NdefRecord creatUriRecord(String uri) {

        Charset utfEncoding = Charset.forName("UTF-8");
        byte[] textBytes = uri.getBytes(utfEncoding);
        NdefRecord ndefRecord = null;/*from   w  w  w  .j  a  v a 2  s  .  co  m*/

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

Related Tutorials