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 = " (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; 
	} 
 
	/** 
	 * Create a connected {@link MCReader} if there is a present Mifare Classic tag. If there is no Mifare Classic tag a error message will be