Android平台NfcV标签Payload读取异常问题求助
Android NFCV标签读取:复现C#端Payload读取结果
在Android Studio Java项目中,尝试读取NdefFormatable和NfcV类型的特定标签Payload。已通过Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);识别标签,创建NfcV对象后执行了以下代码:
NfcV nfcV = NfcV.get(tag); byte[] data = new byte[0]; byte[] id = tag.getId(); if (nfcV != null) { byte[] infoCmd = new byte[2 + id.length]; // set "addressed" flag infoCmd[0] = 0x20; // Get System Information command byte infoCmd[1] = 0x2B; //adding the tag id System.arraycopy(id, 0, infoCmd, 2, id.length); System.arraycopy(id, 0, infoCmd, 2, 8); try { nfcV.connect(); // infoCmd VALUE: [32, 43, 107, 32, -61, -97, 116, 77, 2, -32] // DATA RESULT: [0, 11, 107, 32, -61, -97, 116, 77, 2, -32, -1, 0, 78] data = nfcV.transceive(infoCmd); } catch (IOException e) { e.printStackTrace(); } finally { try { nfcV.close(); } catch (IOException e) { e.printStackTrace(); } } }
问题:nfcV.transceive(infoCmd)返回的数据不符合预期,无法确定是infoCmd指令内容错误,还是该方式无法获取设备Payload。
补充说明:同款NFC设备在C#中可通过ProximityDevice对象获取Payload,代码如下:
ProximityMessage message; var rawMsg = message.Data.ToArray();
需求:需在Android应用中复现C#端rawMsg的结果,实现相同的Payload读取。
内容的提问来源于stack exchange,提问作者Gabriel Palmeri
相关产品推荐
相关产品推荐

