【问题标题】:Android NFC: can we use intent filter with mime type? (android 2.3.3)Android NFC:我们可以使用具有 mime 类型的意图过滤器吗? (安卓 2.3.3)
【发布时间】:2011-03-13 22:55:55
【问题描述】:

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

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

如果我点击一个 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

如果我用这个替换“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 标签时,活动开始。 我在 2.3.3 上使用 Nexus S。

有什么线索吗?

BR, 帕特里克

【问题讨论】:

    标签: android nfc


    【解决方案1】:

    我遇到了类似的问题,可以通过添加类别元素来解决:

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

    -奥利弗

    【讨论】:

    • 确实如此。前段时间有同样的问题。我想知道为什么会这样。文档没有说什么。有人问谷歌吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-19
    • 1970-01-01
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    相关资源
    最近更新 更多