我实现了一个应用程序来读取nfc标签。但是它不能读取带有"android.nfc.action.TECH_DISCOVERED“的标签。下面是我所做的事情:(1)在活动中的AndroidManifest.xml中添加意图过滤器
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED"/>
<meta-data android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>(2)在/res/xml/中添加文件"nfc_tech_filter.xml“如下:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.NfcB</tech>
<tech>android.nfc.tech.NfcF</tech>
<tech>android.nfc.tech.NfcV</tech>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcBarcode</tech>
<tech>android.nfc.tech.NdefFormatable</tech>
<tech>android.nfc.tech.MifareClassic</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
</resources>但我的应用程序无法获得任何TECH_DISCOVERED意图。我发现logcat中有一个错误:
W/RegisteredComponentCache(1404): Unable to load component info ResolveInfo{41fe1748 com.example.nfcapp/.MainActivity m=0x108000}
W/RegisteredComponentCache(1404): org.xmlpull.v1.XmlPullParserException: No android.nfc.action.TECH_DISCOVERED meta-data因此,我解压缩我的nfcapp.apk,并检查"/res/xml/“中的"nfc_tech_filter.xml”是否仍然存在。我不知道为什么它不能解析元数据,或者配置有问题吗?有人能帮我吗?
发布于 2014-10-16 12:06:11
你在你的声明中包括了许可和特写吗?您的最低SDK设置为10吗?元数据标记必须位于意图筛选器之外。
https://stackoverflow.com/questions/26403653
复制相似问题