Code example for NfcAdapter

Methods: enableForegroundDispatch, isEnabled

0
     * @param targetActivity The Activity that is in foreground and wants to 
     * have NFC Intents. 
     * @see #disableNfcForegroundDispatch(Activity) 
     */ 
    public static void enableNfcForegroundDispatch(Activity targetActivity) {
        if (mNfcAdapter != null && mNfcAdapter.isEnabled()) {
 
            Intent intent = new Intent(targetActivity,
                    targetActivity.getClass()).addFlags(
                            Intent.FLAG_ACTIVITY_SINGLE_TOP);
            PendingIntent pendingIntent = PendingIntent.getActivity(
                    targetActivity, 0, intent, 0);
            mNfcAdapter.enableForegroundDispatch(
                    targetActivity, pendingIntent, null, new String[][] {
                            new String[] { MifareClassic.class.getName() } });
        } 
    } 
 
    /** 
     * Disable the NFC foreground dispatch system for the given Activity. 
     * @param targetActivity An Activity that is in foreground and has