下面列出了怎么用android.nfc.tech.NfcBarcode的API类实例代码及写法,或者点击链接到github查看源代码。
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;
}
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;
}