Java Code Examples for android.nfc.Tag#hasTech()

The following examples show how to use android.nfc.Tag#hasTech() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MifareUltralight.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link MifareUltralight} for the given tag.
 * <p>Returns null if {@link MifareUltralight} was not enumerated in
 * {@link Tag#getTechList} - this indicates the tag is not MIFARE
 * Ultralight compatible, or that this Android
 * device does not implement MIFARE Ultralight.
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an MIFARE Ultralight compatible tag
 * @return MIFARE Ultralight object
 */
public static MifareUltralight get(Tag tag) {
    if (!tag.hasTech(TagTechnology.MIFARE_ULTRALIGHT)) return null;
    try {
        return new MifareUltralight(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 2
Source File: NfcA.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NfcA} for the given tag.
 * <p>Returns null if {@link NfcA} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag does not support NFC-A.
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NFC-A compatible tag
 * @return NFC-A object
 */
public static NfcA get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NFC_A)) return null;
    try {
        return new NfcA(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 3
Source File: NfcBarcode.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NfcBarcode} for the given tag.
 *
 * <p>Returns null if {@link NfcBarcode} was not enumerated in {@link Tag#getTechList}.
 *
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NfcBarcode compatible tag
 * @return NfcBarcode object
 */
public static NfcBarcode get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NFC_BARCODE)) return null;
    try {
        return new NfcBarcode(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 4
Source File: NfcB.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NfcB} for the given tag.
 * <p>Returns null if {@link NfcB} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag does not support NFC-B.
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NFC-B compatible tag
 * @return NFC-B object
 */
public static NfcB get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NFC_B)) return null;
    try {
        return new NfcB(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 5
Source File: NdefFormatable.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NdefFormatable} for the given tag.
 * <p>Does not cause any RF activity and does not block.
 * <p>Returns null if {@link NdefFormatable} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag is not NDEF formatable by this Android device.
 *
 * @param tag an NDEF formatable tag
 * @return NDEF formatable object
 */
public static NdefFormatable get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NDEF_FORMATABLE)) return null;
    try {
        return new NdefFormatable(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 6
Source File: Ndef.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link Ndef} for the given tag.
 *
 * <p>Returns null if {@link Ndef} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag is not NDEF formatted, or that this tag
 * is NDEF formatted but under a vendor specification that this Android
 * device does not implement.
 *
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NDEF compatible tag
 * @return Ndef object
 */
public static Ndef get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NDEF)) return null;
    try {
        return new Ndef(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 7
Source File: NfcV.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NfcV} for the given tag.
 * <p>Returns null if {@link NfcV} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag does not support NFC-V.
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NFC-V compatible tag
 * @return NFC-V object
 */
public static NfcV get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NFC_V)) return null;
    try {
        return new NfcV(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 8
Source File: MifareClassic.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link MifareClassic} for the given tag.
 * <p>Does not cause any RF activity and does not block.
 * <p>Returns null if {@link MifareClassic} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag is not MIFARE Classic compatible, or this Android
 * device does not support MIFARE Classic.
 *
 * @param tag an MIFARE Classic compatible tag
 * @return MIFARE Classic object
 */
public static MifareClassic get(Tag tag) {
    if (!tag.hasTech(TagTechnology.MIFARE_CLASSIC)) return null;
    try {
        return new MifareClassic(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 9
Source File: IsoDep.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link IsoDep} for the given tag.
 * <p>Does not cause any RF activity and does not block.
 * <p>Returns null if {@link IsoDep} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag does not support ISO-DEP.
 *
 * @param tag an ISO-DEP compatible tag
 * @return ISO-DEP object
 */
public static IsoDep get(Tag tag) {
    if (!tag.hasTech(TagTechnology.ISO_DEP)) return null;
    try {
        return new IsoDep(tag);
    } catch (RemoteException e) {
        return null;
    }
}
 
Example 10
Source File: NfcF.java    From android_9.0.0_r45 with Apache License 2.0 3 votes vote down vote up
/**
 * Get an instance of {@link NfcF} for the given tag.
 * <p>Returns null if {@link NfcF} was not enumerated in {@link Tag#getTechList}.
 * This indicates the tag does not support NFC-F.
 * <p>Does not cause any RF activity and does not block.
 *
 * @param tag an NFC-F compatible tag
 * @return NFC-F object
 */
public static NfcF get(Tag tag) {
    if (!tag.hasTech(TagTechnology.NFC_F)) return null;
    try {
        return new NfcF(tag);
    } catch (RemoteException e) {
        return null;
    }
}