create NFC Message and return NdefMessage - Android Network

Android examples for Network:NFC Message

Description

create NFC Message and return NdefMessage

Demo Code


//package com.java2s;

import android.nfc.*;

public class Main {
    static NdefMessage createMessage(String content, String mimeType) {
        byte[] contentBytes = content.getBytes();
        byte[] mimeBytes = mimeType.getBytes();

        NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
                mimeBytes, new byte[] {}, contentBytes);
        return new NdefMessage(new NdefRecord[] { textRecord });
    }//from  ww  w.  j a  v a2 s .co m
}

Related Tutorials