Android的NFC写NFCA标签 [英] Android NFC Write NFCA tag

查看:1017
本文介绍了Android的NFC写NFCA标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我尝试写一个NFC在Android 2.3.6(歌Nexus S)的标记。我用的是code从这个例子: http://www.jessechen.net/blog/如何对NFC-上的-的Andr​​oid平台/

I've a problem when I try to write a NFC A tag on Android 2.3.6 (nexus S). I use the code from this example: http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/

更多precisely,当我做Ndef.get(MyTag的)我得到空,所以我不能写我的标签。

More precisely, when I do the Ndef.get(mytag) I get null so I cannot write my tag.

下面是code从中我得到一个空引用(标签值不为空),只有NDEF。

Here is the code from which I get a null references (the 'tag' value is not null), only the ndef.

Ndef ndef = Ndef.get(tag); 

if (ndef != null) {
    ndef.connect();
    if (!ndef.isWritable()) {
        return false;
    }
    if (ndef.getMaxSize() < size) {
        return false;
    }
    ndef.writeNdefMessage(message);
    return true;
}

感谢您对您帮助!

推荐答案

您的标签可能还没有被格式化为NDEF消息存储或可能不能够存储的NDEF消息都没有。 检查是否 NdefFormatable.get(标签)返回的东西不等于

Your tag may not yet be formatted for NDEF message storage or may not be able to store NDEF messages at all. Check whether NdefFormatable.get(tag) returns something unequal to null.

然后使用 NdefFormatable.format(消息)来尝试编写信息。

Then use NdefFormatable.format(message) to try to write your message.

如果 NdefFormatable.get(标签)返回,然后或者Android有没有办法格式化标签或标签是不兼容的,以NDEF存储。 (或者,你可能希望使用TagWriter, https://market.android .COM /详细信息?ID = com.nxp.nfc.tagwriter 格式化并写入你的标记。)

If NdefFormatable.get(tag) returns null, then either Android has no means to format the tag or the tag is incompatible to NDEF storage. (Alternatively, you may want to use TagWriter, https://market.android.com/details?id=com.nxp.nfc.tagwriter to format and write your tag.)

这篇关于Android的NFC写NFCA标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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