Android examples for Network:NFC Record
Create new NFC Image Record
//package com.java2s; import java.io.ByteArrayOutputStream; import java.nio.charset.Charset; import android.graphics.Bitmap; import android.nfc.NdefRecord; public class Main { public static NdefRecord newImageRecord(Bitmap bitmap) { ByteArrayOutputStream out = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); byte[] content = out.toByteArray(); return newMimeRecord("image/jpeg", content); }//from w w w. ja va2 s.c om public static NdefRecord newMimeRecord(String mimeType, byte[] payload) { byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8")); NdefRecord mimeRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, new byte[0], payload); return mimeRecord; } }