get Message As Ndef - Android Network

Android examples for Network:NFC Message

Description

get Message As Ndef

Demo Code


//package com.java2s;

import android.nfc.NdefMessage;
import android.nfc.NdefRecord;

public class Main {
    public static NdefMessage getMessageAsNdef(String message) {
        byte[] textBytes = message.getBytes();
        NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
                "text/plain".getBytes(), new byte[] {}, textBytes);
        return new NdefMessage(new NdefRecord[] { textRecord });
    }//  ww  w.jav  a 2  s .co m
}

Related Tutorials