format NFC Ndef Message - Android Network

Android examples for Network:NFC Message

Description

format NFC Ndef Message

Demo Code


//package com.java2s;
import android.nfc.FormatException;
import android.nfc.NdefMessage;

import android.nfc.Tag;

import android.nfc.tech.NdefFormatable;

public class Main {
    private static void formatNdef(NdefMessage message, Tag tag)
            throws Exception {
        NdefFormatable format = NdefFormatable.get(tag);
        if (format != null) {
            format.connect();// w w w.  ja v  a2s  . c o m
            format.format(message);
        } else {
            throw new FormatException("Tag doesn't support NDEF.");
        }
    }
}

Related Tutorials