Android NFC <tech-list> - 问题

SKA*_*8ce 1 android nfc

id想在android上编写我的第一个NFC应用程序.为此,我使用Android开发人员链接:http://developer.android.com/guide/topics/nfc/index.html

这里用于指定支持的技术,您必须创建一个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.NdefFormatable</tech>
        <tech>android.nfc.tech.MifareClassic</tech>
        <tech>android.nfc.tech.MifareUltralight</tech>
    </tech-list>
</resources>
Run Code Online (Sandbox Code Playgroud)

我的问题是,在标签上我得到以下错误:"错误:找到标签技术列表,其中项目是预期的"

我的申请目标是2.3.3.我认为这必须符合这个目标......

任何的想法?

谢谢!

小智 6

我的应用程序的AndroidManifest.xml文件中的片段,用于接收NFC意图的活动

<activity
        android:name=".activity.ClientActivity"
        android:screenOrientation="portrait"
        android:label="@string/app_name"
        android:description="@string/app_name"
        android:icon="@drawable/ttlogo">
        <intent-filter>
            <action
                android:name="android.nfc.action.TECH_DISCOVERED"/>
        </intent-filter>
        <meta-data
            android:resource="@xml/nfc_tech_filter"
            android:name="android.nfc.action.TECH_DISCOVERED" />
        <intent-filter>
            <action
                android:name="android.nfc.action.TAG_DISCOVERED" />
            <category
                android:name="android.intent.category.DEFAULT" />
        </intent-filter>
        <intent-filter>
            <action
                android:name="android.intent.action.VIEW" />
            <category
                android:name="android.intent.category.DEFAULT" />
            <data
                android:scheme="http"
                android:host="www.ttag.be" />
        </intent-filter>
    </activity>
Run Code Online (Sandbox Code Playgroud)

包含过滤器定义的文件位于res/xml/nfc_tech_filter.xml中,如下所示

<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!--  Touchatag tag -->
<tech-list>
    <tech>android.nfc.tech.NfcA</tech>        
    <tech>android.nfc.tech.Ndef</tech>
    <tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
<!--  DESFire tag -->
<tech-list>
    <tech>android.nfc.tech.NfcA</tech>        
    <tech>android.nfc.tech.IsoDep</tech>
    <tech>android.nfc.tech.NdefFormatable</tech>
</tech-list>
<!--  Any Tag -->
<tech-list>
    <tech>android.nfc.tech.NfcA</tech>        
</tech-list>
Run Code Online (Sandbox Code Playgroud)


小智 5

android SDK 文档告诉:将此文件保存(您可以将其命名为任何您想要的名称)

 <project-root>/res/xml/ 
Run Code Online (Sandbox Code Playgroud)文件夹。

所以,您可能将 xml 文件保存在错误的文件夹中。(您是否将其保存在<project-root>/res/values/