在 Nexus S 上安装 Android 2.3.4 后,NFC 应用程序不再启动
在我的 Nexus S 上安装 Android 2.3.4 后,NFC 应用程序不再启动。
我尝试过谷歌文档中描述的三个意图(NDEF_DISCOVERED、TECH_DISCOVERED、TAG_DISCOVERED),但其中任何一个都解决了问题,Nexux S 继续打开默认的谷歌应用程序并忽略我的应用程序。
我在清单中有这个
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
,如果我没记错的话,新闻 2.3.3 似乎支持它,为什么 Nexus S 忽略它?
你能帮我一下吗?
此致, 雨果.
After installing Android 2.3.4 on my Nexus S, NFC Apps doesn´t start anymore.
I've tried with the three intents (NDEF_DISCOVERED,TECH_DISCOVERED,TAG_DISCOVERED) described in google documentation, but any of them solves the problem, Nexux S keeps on opening default google applications and ignore my app.
I had this in the manifest
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
and if I am not wrong it seems to be supported in news 2.3.3, why the Nexus S ignore it?
Could you help me please.
Best Regards,
Hugo.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将其添加到您的意图过滤器中:
扫描标签时,Android 应显示一个弹出窗口,询问哪个应用程序来处理它。
更新
根据您评论中的其他信息,问题是您的标签包含 Android 可以识别的信息。在本例中,它是一个 URL。由于 Android 可以找到可以处理 url 的应用程序(默认 NFC 应用程序),因此该应用程序将优先并被调用,而不是简单处理标签发现的应用程序。仅当没有其他意图过滤器与标签匹配时才会调度标签发现。引用文档:
因此,您还必须声明标签来处理标签中的消息。 您还需要准确指定您要定位的数据类型(在本例中为网址),否则 Google Android 应用程序仍会优先考虑网址。您可以在Android NFC 页面
You need to add this to your intent filters:
When a tag is scanned, Android should show a popup asking which app to handle it.
Update
Based on additional info from your comment, the problem is that your tag contains information which is recognized by Android. In this case, that is a URL. Since Android can find an app (the default NFC app) which can handle urls, then that app will take priority and be called instead of an app which simple handles tag discovery. Tag discovery is only dispatched if no other intent filter matched the tag. To quote the docs:
So you must declare your tag to handle messages in the tags as well. You need to specify exactly the type of data you are targeting as well (in this case, urls), else the Google Android app will still take precedence for URLs. You can read more information on the Android NFC page
您还必须在意图过滤器中添加数据。请参考 http://developer.android.com/guide/ topic/nfc/nfc.html#tech-disc
并查看“过滤 NFC 意图”中的“ACTION_NDEF_DISCOVERED”。
You have to also add data in the intent filter. Please refer to http://developer.android.com/guide/topics/nfc/nfc.html#tech-disc
and look under ACTION_NDEF_DISCOVERED in Filtering for NFC intents.