Create new NFC Uri Record Sub - Android Network

Android examples for Network:NFC Record

Description

Create new NFC Uri Record Sub

Demo Code


//package com.java2s;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;

import android.net.Uri;

public class Main {
    static boolean newUriRecordSub(ByteArrayOutputStream os, Uri uri,
            String prefix, int code) throws IOException {
        if (uri.toString().startsWith(prefix)) {
            os.write(code);//from   w w w.  j a v a  2  s.  co m
            os.write(uri.toString().substring(prefix.length())
                    .getBytes(Charset.forName("UTF-8")));
            return true;
        } else {
            return false;
        }
    }
}

Related Tutorials