从NFC标签读取启动应用 [英] Launching app from NFC tag reading
问题描述
我已经阅读并阅读过,但是我不明白当我触摸NFC标签(使用TagWriter并在{X}上弹出列表)时,要使应用程序启动到底需要做些什么
I've read and read, but I can't understand what do I need to do exactly to make the application launch when I touch a NFC tag (a list pops with TagWriter and on{X})
我已将其添加到我的应用程序主活动中(在清单中)
I've added this to my applications Main Activity (in Manifest)
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
</intent-filter>
我还使用应用程序内的application/com.pgsideris.aeglea
NDEF数据读写标签
And I also write and read the tag with application/com.pgsideris.aeglea
NDEF Data within the application
我欢迎您提供一些细节,因为大多数其他帖子所提供的内容都不多,而且它们提供的链接使我有些困惑.
I would welcome some detail, as most other posts don't offer much and the links they provide have confused me somewhat.
推荐答案
弹出这些应用程序的主要原因是您正在过滤mimetype文本/纯文本",并且如果您编写了带有该mimetype的NFC标签,则全部包括您自己的应用程序在内的所有应用程序都将响应该标记.
The main reason for those applications to pop-up is you are filtering for mimetype "text/plain" and if you wrote an NFC-tag with that mimetype all applications including your own application will respond to the tag.
如果您正确编写了NFC标签,则可能发布一些代码来验证这一点,您应该过滤出MIME类型"application/com.pgsideris.aeglea",从而得到以下过滤器:
If you are correctly writing the NFC-tag, perhaps post some code to verify that, you should filter for mimetype "application/com.pgsideris.aeglea" this results in the following filter:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="application/com.pgsideris.aeglea" />
</intent-filter>
这篇关于从NFC标签读取启动应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!