gpt4 book ai didi

Android NFC - 问题

转载 作者:行者123 更新时间:2023-11-29 14:22:17 28 4
gpt4 key购买 nike

我想在 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>

我的问题是,在标签处出现以下错误:“错误:在需要项目的位置找到标签技术列表”

我的应用程序的目标是 2.3.3。我认为这必须在这个目标上起作用......

有什么想法吗?

谢谢!

最佳答案

我的应用的 AndroidManifest.xml 文件中接收 NFC Intent 的 Activity 的 fragment

<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>

包含过滤器定义的文件位于 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>

关于Android NFC <tech-list> - 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6841470/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com