Android的NFC:我们可以使用意图过滤MIME类型? (安卓2.3.3) [英] Android NFC: can we use intent filter with mime type? (android 2.3.3)

查看:347
本文介绍了Android的NFC:我们可以使用意图过滤MIME类型? (安卓2.3.3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,当窃听包含特定的MIME类型的NFC标签,开始一个活动。
我做了一个标记的MIME类型为text / plain的,并在清单中加入这样的:

I'm trying to start an activity when "tapping" a nfc tag containing a specific mime type. I made a tag with the mime type "text/plain", and added this in the manifest:

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
  <data android:mimeType="text/plain" />
</intent-filter>

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

If I tap a nfc tag, nothing happen, even if the intent seems right, here is what I see in logs:

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

如果我用这一个取代哑剧意图过滤器

If I replace the "mime intent-filter" by this one:

<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标签。
我使用的是2.3.3 Nexus S的。

the activity is started when a tap the nfc tag. I'm using a Nexus S on 2.3.3.

任何线索?

BR,
帕特里克

BR, Patrick

推荐答案

我也有类似的问题,可以通过添加一个类别元素解决这个问题:

I had a similar problem and could solve it by adding a category element:

<intent-filter>
  <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
  <data android:mimeType="text/plain"/>

  <category android:name="android.intent.category.DEFAULT"/>

</intent-filter>

-Oliver

-Oliver

这篇关于Android的NFC:我们可以使用意图过滤MIME类型? (安卓2.3.3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆