我正在尝试在“点击”包含特定 MIME 类型的 nfc 标签时开始一项 Activity 。 我制作了一个 mime 类型为“text/plain”的标签,并将其添加到 list 中:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain" />
</intent-filter>
如果我点击一个 nfc 标签,没有任何反应,即使 Intent 看起来是正确的,这是我在日志中看到的:
03-13 23:36:56.871: INFO/ActivityManager(114): Starting: Intent { act=android.nfc.action.NDEF_DISCOVERED typ=text/plain flg=0x10000000 (has extras) } from pid 192
如果我用这个替换“mime intent-filter”:
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
</intent-filter>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/filter_nfc"/>
当点击 nfc 标签时, Activity 开始。 我在 2.3.3 上使用 Nexus S。
有什么线索吗?
BR, 帕特里克
最佳答案
我遇到了类似的问题,可以通过添加类别元素来解决:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
-奥利弗
关于安卓 NFC : can we use intent filter with mime type? (安卓 2.3.3),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5293056/