Android 2.3.3 上的 NFC 读取问题
我正在尝试制作一个需要读取 NFC 标签的应用程序。但是,当我将标签放在 Nexus S 上时,“选择操作”菜单中会列出另外两个应用程序(Tags 和 TagWriter),而我的应用程序未列出。我在互联网上搜索过,主要找到了有关清单的内容。我在遵循开发人员指南时创建了清单。
我认为应用程序本身可以工作,但如果应用程序无法识别标签,我无法真正测试它。任何帮助将不胜感激!
这是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nfc" android:versionCode="1" android:versionName="1.0">
<!-- Permissions -->
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- SDK version -->
<uses-sdk android:minSdkVersion="10" />
<!-- Features -->
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<!-- Application settings -->
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- Simulator activity -->
<activity android:name=".activity.NfcActivity"" android:theme="@android:style/Theme.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- User activity -->
<activity android:name=".activity.TagActivity" android:theme="@android:style/Theme.Light">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
I'm trying to make an app that needs to read NFC tags. However, when I hold a tag to my Nexus S, two other apps (Tags and TagWriter) are listed in the "Select an action" menu, while my app isn't listed. I've searched the internet, and I mostly found things about the manifest. I created the manifest when I was following the developer's guide.
I think the application itself works, but I can't really test it if the app doesn't recognize the tags. Any help will be very appreciated!
Here's my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nfc" android:versionCode="1" android:versionName="1.0">
<!-- Permissions -->
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- SDK version -->
<uses-sdk android:minSdkVersion="10" />
<!-- Features -->
<uses-feature android:name="android.hardware.nfc" android:required="true" />
<!-- Application settings -->
<application android:icon="@drawable/icon" android:label="@string/app_name">
<!-- Simulator activity -->
<activity android:name=".activity.NfcActivity"" android:theme="@android:style/Theme.Light">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- User activity -->
<activity android:name=".activity.TagActivity" android:theme="@android:style/Theme.Light">
<intent-filter>
<action android:name="android.nfc.action.TAG_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很有趣,我将其与我自己的清单进行了比较(我的应用程序出现在活动选择对话框中),它看起来非常相似,至少我找不到任何区别 - 可能你会......我记得我遇到了同样的问题,但我在清单中遗漏了一部分,但下面的 XML 对我有用:
BR
斯坦,
petr.mazanec[at]mautilus.com
this is interesting, I have compared this with my own manifest (my application appears in the activity selection dialog) and it looks pretty similar, at least I cannot find any difference - might be you will... I remember I had the same problem, but I was missing one piece in manifest, but the XML below is working for me:
BR
STeN,
petr.mazanec[at]mautilus.com