Code example for Tag

Methods: getId, getTechList

0
    public static int treatAsNewTag(Intent intent, Context context) {
        // Check if Intent has a NFC Tag. 
        if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {
            Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
            mTag = tag;
            mUID = tag.getId();
 
            // Show Toast message with UID. 
         /*  String id = context.getResources().getString( 
                    R.string.info_new_tag_found) + " (UID: "; 
            id += byte2HexString(tag.getId()); 
            id += ")"; 
            Toast.makeText(context, id, Toast.LENGTH_LONG).show();    */ 
 
            // Return "1" if device supports Mifare Classic. "0" otherwise. 
            return (Arrays.asList(tag.getTechList()).contains(
                    MifareClassic.class.getName())) ? 1 : 0;
        } 
        return -1; 
    } 
 
4
CodeRank

Further Reading