Obtain a reference to the ISO 14443-4 card detected at the NFC interface from the Intent representing the "tag detected" event - Android Network

Android examples for Network:NFC Tag

Description

Obtain a reference to the ISO 14443-4 card detected at the NFC interface from the Intent representing the "tag detected" event

Demo Code


//package com.java2s;

import android.content.Intent;

import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.IsoDep;

public class Main {
    /**/* ww w.  j  a  v  a2 s.c o m*/
     * Obtain a reference to the ISO 14443-4 card detected at the NFC interface from the
     * Intent representing the "tag detected" event
     * @param intent object representing the "tag detected" event
     * @return reference to the ISO card
     */
    public static IsoDep getIsoTag(Intent intent) {
        Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
        if (tag != null) {
            return IsoDep.get(tag);
        } else {
            return null;
        }
    }
}

Related Tutorials