简体   繁体   English

android-尝试检测任何NFC标签

[英]android - trying to detect any NFC tag

I got a plastic card with an NFC tag of unknown type, when I touch my Nexus 7 with it a short sound is playing, nothing more. 我收到了一张带有未知类型NFC标签的塑料卡,当我触摸Nexus 7时,它发出的声音很短,仅此而已。 I was curious if I can react to NFC tags from my app, so I declared the following filters for my Activity since I don't know the type of the Tag: 我很好奇我是否可以对应用程序中的NFC标签做出反应,因此我为Activity声明了以下过滤器,因为我不知道标签的类型:

 <intent-filter>
            <action android:name="android.intent.action.MAIN" />
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
            <action android:name="android.nfc.action.TECH_DISCOVERED" />
            <action android:name="android.nfc.action.TAG_DISCOVERED" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

But it does nothing when I touch the tag. 但是当我触摸标签时它什么也没做。 It also does not react to an XPERIA smart tag. 它还不会对XPERIA智能标记作出反应。 What am I missing? 我想念什么? Can detect NFC tags without knowing the type of the tag? 是否可以在不知道标签类型的情况下检测NFC标签? I mean perform the same simple action (like setting a text) when a tag touch is detected. 我的意思是在检测到标签触摸时执行相同的简单操作(如设置文本)。

代替<category android:name="android.intent.category.LAUNCHER" />您需要使用<category android:name="android.intent.category.DEFAULT"/>

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

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