简体   繁体   English

读取使用NFC工具编写的NFC标签

[英]Read NFC tag written with NFC Tools

I followed this tutorial: https://www.codexpedia.com/android/android-nfc-read-and-write-example/ If I use I can read and write the tags, if I use when I try to read a NFC written with NFC tools, android starts trigger but not my app. 我遵循了本教程: https : //www.codexpedia.com/android/android-nfc-read-and-write-example/如果使用,我可以读写标签,如果尝试读取NFC时使用用NFC工具编写的android启动触发器,但不启动我的应用程序。 It is possibile to read NFC tags written with other apps? 可以读取用其他应用程序编写的NFC标签吗? thanks 谢谢

There is a NFC service running in the background. 后台运行NFC服务。 When tag is detected it processes that event. 当检测到标签时,它将处理该事件。 It identifies the type of Tag and then creates an intent accordingly. 它标识标签的类型,然后相应地创建一个意图。 There can be more than one application in Android device that are interested to process the tag. Android设备中可能有多个应用程序需要处理标签。 The tag dispatch system of the NFC Service decides the application to be launched. NFC服务的标签分发系统决定要启动的应用程序。

In order to let NFC service know that your app is interested, your app should declare an intent filter with intent's action among the following: ACTION_NDEF_DISCOVERED, ACTION_TECH_DISCOVERED, ACTION_TAG_DISCOVERED. 为了让NFC服务知道您的应用感兴趣,您的应用应声明一个具有意图操作的意图过滤器,其中包括:ACTION_NDEF_DISCOVERED,ACTION_TECH_DISCOVERED,ACTION_TAG_DISCOVERED。

Note that filtering for TECH_DISCOVERED intent needs an additional xml file that has one or more elements. 请注意,针对TECH_DISCOVERED意图进行过滤需要一个具有一个或多个元素的附加xml文件。 All the listed techs in it should be supported by tag for a match. 标记中支持其中列出的所有技术,以进行匹配。 This file name should be specified in intent-filter for tech. 该文件名应在技术的意图过滤器中指定。

Refer to https://developer.android.com/guide/topics/connectivity/nfc/nfc#dispatching for complete details. 有关完整的详细信息,请参阅https://developer.android.com/guide/topics/connectivity/nfc/nfc#dispatching

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM