Android NFC <tech-list> - 问题

标签 android nfc

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

相关文章:

android - Ionic 3 - 读取 NFC 卡吗?

java - 如何在Android钱包应用程序中检测POS交易?

java - 实现自定义 NFC 管理器的最简单方法是什么?

php - 如何修复空对象引用上的 java.lang.String org.json.JSONObject.toString()'?

android - 使用 DownloadManager 下载视频文件时应用程序在 Android 10 上崩溃

java - 使用 viewpager.setCurrentItem(position) 传递一些数据

android - 通过调用从 Android 发送传真(不是在线服务)

android - 如何在 WebAppInterface 类中运行 webview.loadurl?

nfc - 由于 RSA key 对生成,安装 java 卡小程序失败

android - 读取 Mifare Classic 返回奇怪的字符