0
我实现了一个应用程序来读取nfc标签。但它无法读取标签“android.nfc.action.TECH_DISCOVERED”。这里有事情,我做的事: (1)在AndroidManifest.xml活动中添加意图过滤没有android.nfc.action.TECH_DISCOVERED元数据
<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,并勾选“nfc_tech_filter.xml”仍然存在于“/ RES/XML /”。我不是为什么它不能解析元数据或配置中的错误? 有人可以帮助我吗?
您是对的。元数据应该在意图过滤器之外。这个问题已经消失。 – 2014-10-16 12:11:12