使手机NFC阅读器更快

时间:2017-12-24 10:47:07

标签: android tags nfc mifare

我需要阅读NFC卡才能上课。现在我正在使用NFC但是读取每张卡需要两秒钟,这太慢了。是否可以将其减少到不到一秒钟?

这是我目前的代码:

@Override
protected void onNewIntent(Intent intent) {
    String uidhex1;
    String uid;
    Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
    ndef = IsoDep.get(tag);

    if (ndef != null) {
        try {
            ndef.connect();
            CommandAPDU cmd = new CommandAPDU("9060000000".toCharArray());
            byte[] result = ndef.transceive(cmd.getBytes());
            cmd.SetString("90af000000".toCharArray());
            result = ndef.transceive(cmd.getBytes());
            cmd.SetString("90af000000".toCharArray());
            result = ndef.transceive(cmd.getBytes());
            uid = Utils.bytesToHex(result);
            uidhex1 = uid.substring(0, 14);
            long outputDecimal = Long.parseLong(uidhex1, 16);
            String mancardId = String.valueOf(outputDecimal);
            EventBus.getDefault().post(new NfcDetectEvent(mancardId));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

0 个答案:

没有答案