早上好,我无法获得地图,该怎么办? 这是我的代码:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
Log.d(TAG, "onNewIntent");
// check for NFC related actions
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
TextView lata = (TextView) findViewById(R.id.tv);
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
lata.setText(tag.toString());
Tag tag1 = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
byte[] id = tag.getId();
}
}
答案 0 :(得分:1)
继续执行以下代码行以获取标签ID:
StringBuilder tagInfo = new StringBuilder();
byte[] tagId = tag.getId();
for (byte aTagId : tagId) {
tagInfo.append(Integer.toHexString(aTagId & 0xFF)).append(" ");
}
tagInfo.append("\n");
同时获取卡片的技术列表
String[] techList = tag.getTechList();
tagInfo.append("\nTech List\n");
tagInfo.append("length = " + techList.length + "\n");
for (int i = 0; i < techList.length; i++) {
tagInfo.append(techList[i] + "\n ");
}
然后您可以执行tagInfo.toString().trim();
并使用将tagInfo设置为textview来显示数据。