get NFC Ndef Text Filter - Android Network

Android examples for Network:NFC Ndef

Description

get NFC Ndef Text Filter

Demo Code


//package com.java2s;

import android.annotation.SuppressLint;

import android.content.IntentFilter;
import android.content.IntentFilter.MalformedMimeTypeException;

import android.nfc.NfcAdapter;

import android.util.Log;

public class Main {
    private static final String TAG = "NfcFilter";

    @SuppressLint("InlinedApi")
    public static IntentFilter getNdefTextFilter() {
        IntentFilter ndefIntentFilter = new IntentFilter(
                NfcAdapter.ACTION_NDEF_DISCOVERED);
        try {//from w w  w .j a  v a 2s. co  m
            ndefIntentFilter.addDataType("text/plain");
        } catch (MalformedMimeTypeException e) {
            Log.e(TAG, "ndefFilter???????", e);
        }
        return ndefIntentFilter;
    }
}

Related Tutorials