我正在使用 Nexus S 测试支持 NFC 的 Android/AIR 应用程序。
我的 NFC 标签上有一个示例 URL,例如“http://www.google.com”。
我想捕获标签上的网址(或任何文本)以便在应用程序中使用。
点击标签后,手机会在浏览器中打开网址。
我想知道 list 中是否缺少某些内容,或者链接是否始终由浏览器处理。我看过docs我什至添加了特定 URL 的方案,但仍然没有成功。
我的 list 如下。感谢您的任何意见。
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:name="android.hardware.nfc" android:required="true"/>
<application android:debuggable="true">
<activity>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED"/>
<data android:mimeType="text/plain" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
最佳答案
NFC 标签上的 URL 与 NFC 标签上的纯文本消息不同。它们有不同的消息类型。您的 list 列出了纯文本消息的 2 个 Intent 过滤器(最后一个实际上永远不会被触发,TAG_DISCOVERED Intent 永远不会包含来自标记的任何数据)。 要匹配您的示例 URL,请尝试:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:scheme="http" android:host="www.google.com" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
另请参阅http://developer.android.com/guide/topics/nfc/nfc.html#ndef-disc更详细的解释NDEF_DISCOVERED
和 http://developer.android.com/guide/topics/manifest/data-element.html有关 <data>
中可以包含哪些内容的完整文档元素。
关于android - AIR/Android NFC 标签正在打开浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10608576/