Android NFC:异常“收发失败"使用transceive()时 [英] Android NFC: Exception "transceive failed" when using transceive()

查看:1201
本文介绍了Android NFC:异常“收发失败"使用transceive()时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Samsung Galaxy S3和支持NfcAIsoDep(Mifare DESFire EV1)的智能卡之间进行通信.为此,我启用了forgeground调度,并在发现标签后启动了任务.任务中的代码如下所示:

I'm trying to communicate between a Samsung Galaxy S3 and a smartcard that supports NfcA and IsoDep (Mifare DESFire EV1). To do this, I enabled forgeground dispatch and started a task when a tag is discovered. The code in the task looks like this:

IsoDep isoDep = IsoDep.get(tag);

byte[] selectCommand = {
        (byte)0x00, // CLA
        (byte)0xA4, // INS
        (byte)0x04, // P1
        (byte)0x00, // P2
        (byte)0x0A, // LC
        (byte)0x01,(byte)0x02,(byte)0x03,(byte)0x04,(byte)0x05,(byte)0x06,(byte)0x07,(byte)0x08,(byte)0x09,(byte)0xFF, // AID
        (byte)0x7F  // LE
};

try {
    isoDep.connect();
    byte[] response = isoDep.transceive(selectCommand);
    String result = bytesToString(response);
    isoDep.close();
    return result;
} catch (Exception e) {
    e.printStackTrace();
}

收发方法抛出此异常:

java.io.IOException: Transceive failed

IsoDep的所有其他方法(如getTimeout())可以无错误地执行.增加超时时间不会改变行为.选择命令中具有AID的小程序位于卡上.我也尝试使用NfcA类.但随后出现异常标签丢失".

All other methods of IsoDep (like getTimeout()) can be executed without error. Increasing the timeout doesn't change the behaviour. The applet with the AID in the select command is present on the card. I also tried to use the NfcA class. But then I get the exception "tag is lost".

Galaxy S3可能是问题吗?

Could the Galaxy S3 be the problem?

推荐答案

我刚刚在另一部手机上尝试了相同的应用程序,并且该应用程序没有任何问题. Galaxy S3确实是问题所在.

I just tried the same app on another phone and it worked without any problems. The Galaxy S3 is indeed the problem.

这篇关于Android NFC:异常“收发失败"使用transceive()时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆