android.nfc.tech.TagTechnology Java Examples
The following examples show how to use
android.nfc.tech.TagTechnology.
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: Tag.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private static HashMap<String, Integer> getTechStringToCodeMap() { HashMap<String, Integer> techStringToCodeMap = new HashMap<String, Integer>(); techStringToCodeMap.put(IsoDep.class.getName(), TagTechnology.ISO_DEP); techStringToCodeMap.put(MifareClassic.class.getName(), TagTechnology.MIFARE_CLASSIC); techStringToCodeMap.put(MifareUltralight.class.getName(), TagTechnology.MIFARE_ULTRALIGHT); techStringToCodeMap.put(Ndef.class.getName(), TagTechnology.NDEF); techStringToCodeMap.put(NdefFormatable.class.getName(), TagTechnology.NDEF_FORMATABLE); techStringToCodeMap.put(NfcA.class.getName(), TagTechnology.NFC_A); techStringToCodeMap.put(NfcB.class.getName(), TagTechnology.NFC_B); techStringToCodeMap.put(NfcF.class.getName(), TagTechnology.NFC_F); techStringToCodeMap.put(NfcV.class.getName(), TagTechnology.NFC_V); techStringToCodeMap.put(NfcBarcode.class.getName(), TagTechnology.NFC_BARCODE); return techStringToCodeMap; }
Example #2
Source File: TestUtilities.java From android-nfc-lib with MIT License | 5 votes |
public Tag mockTag(String technology) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException { // For future reference // Parameters : byte[] b = {0x8}; String ndefClass = "android.nfc.tech.Ndef"; // FieldName which marks the capacity of the tag String extraNdefMaxlength = (String) Class.forName(ndefClass).getField("EXTRA_NDEF_MAXLENGTH").get(null); // FieldName which marks the tags writability String cardWritableStateField = (String) Class.forName(ndefClass).getField("EXTRA_NDEF_CARDSTATE").get(null); // Field to mark tag R/W int cardWritable = Class.forName(ndefClass).getField("NDEF_MODE_READ_WRITE").getInt(null); Bundle techExtras = new Bundle(); techExtras.putInt(extraNdefMaxlength, 2048); techExtras.putInt(cardWritableStateField, cardWritable); Bundle[] extras = {techExtras}; int[] technologies = {TagTechnology.class.getField(technology.toUpperCase()).getInt(null)}; //https://android.googlesource.com/platform/frameworks/base.git/+/android-4.3_r2/core/java/android/nfc/tech/TagTechnology.java // https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/nfc/Tag.java :376 Parcel parcel = Parcel.obtain(); parcel.writeByteArray(b); //Sets the ID parcel.writeIntArray(technologies); // Sets the technology to NDEF parcel.writeArray(extras); // Needed to set properties for NDEF tag parcel.writeInt(1); // Service handle parcel.writeInt(1); // Indicating a mock return Tag.CREATOR.createFromParcel(parcel); }
Example #3
Source File: Tag.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private String[] generateTechStringList(int[] techList) { final int size = techList.length; String[] strings = new String[size]; for (int i = 0; i < size; i++) { switch (techList[i]) { case TagTechnology.ISO_DEP: strings[i] = IsoDep.class.getName(); break; case TagTechnology.MIFARE_CLASSIC: strings[i] = MifareClassic.class.getName(); break; case TagTechnology.MIFARE_ULTRALIGHT: strings[i] = MifareUltralight.class.getName(); break; case TagTechnology.NDEF: strings[i] = Ndef.class.getName(); break; case TagTechnology.NDEF_FORMATABLE: strings[i] = NdefFormatable.class.getName(); break; case TagTechnology.NFC_A: strings[i] = NfcA.class.getName(); break; case TagTechnology.NFC_B: strings[i] = NfcB.class.getName(); break; case TagTechnology.NFC_F: strings[i] = NfcF.class.getName(); break; case TagTechnology.NFC_V: strings[i] = NfcV.class.getName(); break; case TagTechnology.NFC_BARCODE: strings[i] = NfcBarcode.class.getName(); break; default: throw new IllegalArgumentException("Unknown tech type " + techList[i]); } } return strings; }
Example #4
Source File: NfcTagHandler.java From 365browser with Apache License 2.0 | 4 votes |
protected NfcTagHandler(TagTechnology tech, TagTechnologyHandler handler) { mTech = tech; mTechHandler = handler; }