相关疑难解决方法(0)

Android NFC:我们可以使用mime类型的intent过滤器吗?(android 2.3.3)

我正在尝试在"点击"包含特定mime类型的nfc标记时启动一个活动.我使用mime类型"text/plain"制作了一个标签,并将其添加到清单中:

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
  <data android:mimeType="text/plain" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

如果我点击一个nfc标签,没有任何事情发生,即使意图似乎正确,这是我在日志中看到的:

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
Run Code Online (Sandbox Code Playgroud)

如果我用这个替换"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"/>
Run Code Online (Sandbox Code Playgroud)

当点击nfc标签时,活动开始.我在2.3.3上使用Nexus S.

有线索吗?

BR,帕特里克

android nfc

2
推荐指数
1
解决办法
5503
查看次数

标签 统计

android ×1

nfc ×1