Android的NFC样品展示 - 读取标签唯一的虚假信息 [英] Android Nfc Sample Demo - reads only fake information from the Tag

查看:119
本文介绍了Android的NFC样品展示 - 读取标签唯一的虚假信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了NFC演示从谷歌,但它doesn't读取标签。 - >它只是提供了一些fakeTag信息的信息。有没有人一个想法,在那里我可以改变样品从NFC标签阅读?或者有一个人工作的NFC演示的联系?

I just installed the Nfc Demo from google, but it doesn´t read the information from the Tag.-> It just provides some fakeTag information. Has anybody an idea, where I can change the sample to read from the nfc Tag? Or has somebody a working nfc demo for the nexus?

如果我们能带来NFC的演示工作,许多人将不得不开发一个NFC演示自己的可能性。

If we could bring a nfc demo to work, many people would have the possibility to develop a nfc demo on their own.

最好的问候 亚历山大

推荐答案

我有同样的问题,得到的标签ID。我得到了一些B @ 2346323143作风数据到屏幕。我得到它的工作是这样的:

I had the same problem getting tag id. I got some B@2346323143 style data to screen. I got it to work like this:

字节[] byte_id = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);

您需要的byte []转换为十六进制的字符串。例如使用下面的方法。

You need to convert byte[] to hex string. For example using following method.

private static final byte[] HEX_CHAR_TABLE = { (byte) '0', (byte) '1',
        (byte) '2', (byte) '3', (byte) '4', (byte) '5', (byte) '6',
        (byte) '7', (byte) '8', (byte) '9', (byte) 'A', (byte) 'B',
        (byte) 'C', (byte) 'D', (byte) 'E', (byte) 'F' };

public static String getHexString(byte[] raw, int len) {
    byte[] hex = new byte[2 * len];
    int index = 0;
    int pos = 0;

    for (byte b : raw) {
        if (pos >= len)
            break;

        pos++;
        int v = b & 0xFF;
        hex[index++] = HEX_CHAR_TABLE[v >>> 4];
        hex[index++] = HEX_CHAR_TABLE[v & 0xF];
    }

    return new String(hex);
}

这篇关于Android的NFC样品展示 - 读取标签唯一的虚假信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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