我正在尝试在"点击"包含特定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,帕特里克
我遇到了类似的问题,可以通过添加一个category元素来解决它:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
-Oliver
| 归档时间: |
|
| 查看次数: |
5503 次 |
| 最近记录: |