简体   繁体   English

没有android.nfc.action.TECH_DISCOVERED元数据

[英]No android.nfc.action.TECH_DISCOVERED meta-data

I implement a app to read nfc tag. 我实现了一个应用程序来读取nfc标签。 But it can't read tag with "android.nfc.action.TECH_DISCOVERED". 但是它无法读取带有“ android.nfc.action.TECH_DISCOVERED”的标签。 Here are things I did: (1) add intent filter in AndroidManifest.xml within activity 这是我做的事情:(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) add file "nfc_tech_filter.xml" in /res/xml/ like this: (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>

But my app can't get any TECH_DISCOVERED intent. 但是我的应用程序无法获得任何TECH_DISCOVERED意图。 I find there is an error in logcat: 我发现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

So I unzip my nfcapp.apk, and check the "nfc_tech_filter.xml" is still there in "/res/xml/". 因此,我将我的nfcapp.apk解压缩,并检查“ / res / xml /”中是否仍存在“ nfc_tech_filter.xml”。 I don't why it cannot parse the meta-data or is something wrong in configuration? 我为什么不解析元数据或者配置有问题? Is anyone can help me? 有人可以帮助我吗?

Have you included the permission and the feature in your Manifest? 您是否在清单中包含了权限和功能? Is your minimum SDK set to 10? 您的最低SDK是否设置为10? The meta-data tag must be OUTSIDE your intent-filter 元数据标签必须在您的意图过滤器之外

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM