Tag myTag = (Tag) intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Log.i("tag ID",myTag.getId().toString());
这给我一个ID如“[B @ 40521c40”,但这个ID改变每一个阅读.
任何帮助将不胜感激.
谢谢.
解决方法
您仍然需要将字节转换为字符串:
private String bytesToHexString(byte[] src) { StringBuilder stringBuilder = new StringBuilder("0x"); if (src == null || src.length <= 0) { return null; } char[] buffer = new char[2]; for (int i = 0; i < src.length; i++) { buffer[0] = Character.forDigit((src[i] >>> 4) & 0x0F,16); buffer[1] = Character.forDigit(src[i] & 0x0F,16); System.out.println(buffer); stringBuilder.append(buffer); } return stringBuilder.toString(); }