问题
id want to write my first NFC-application on android. For this i use the android developers link: http://developer.android.com/guide/topics/nfc/index.html
Here for specifying the supported technologies you have to create a xml file like this:
<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>
My problem is, at the tag i get following error: "error: Found tag tech-list where item is expected"
The target of my application is 2.3.3. I think this has to work on this target ...
Any idea?
Thanks!
回答1:
Snippet from my app's AndroidManifest.xml file for the activity that receives NFC intents
<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>
The file containing the filter definition is in res/xml/nfc_tech_filter.xml and looks like this
<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>
回答2:
The android SDK doc tell: Save this file (you can name it anything you wish) in the
<project-root>/res/xml/
folder.
so,you probably save your xml file in an wrong folder.(did you save it in <project-root>/res/values/
)
回答3:
Put each of the <tech>
item in a separate <tech-list>
node.
回答4:
In my case I had to create the directory xml
inside res
.
It was not very clear for me. Hope it helps someone.
来源:https://stackoverflow.com/questions/6841470/android-nfc-tech-list-problem