NDEF意图过滤器不会在Android中6启动应用程序,7
嘿*ers ...NDEF意图过滤器不会在Android中6启动应用程序,7
我支持具有NFC读取功能,它需要通过扫描NFC标签,打开该应用程序的应用程序。它适用于4.3和所有4.X版本android.nfc.action.NDEF_DISCOVERED
intent-filter
。
所以URL是这样的:http://www.example.com/nfc/NFC00000001
而且我看过几乎快要NFC意图过滤器每一个可能的相关答案。
我能够通过代码获取NFC标签,如果活动已打开但这不是我所需要的。
的NFC读写器的应用程序显示我的标签是
NXP MIFARE超轻(超轻C) - NTAG213
而且它支持
NFCA,MifareUltralight,NDEF
不适用于(Nexus 4),Android 6(OnePlus 3)和Andorid 7.1.1(Nexus 6P)。我没有其他Android 6和7设备,因此我无法在Android 5上进行测试。
我想有和没有android.nfc.action.TECH_DISCOVERED
我几乎尝试了每一个可能的选项,这是我最后的办法,不能太工作(应用程序未启动)。
<activity
android:name=".activities.QRActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:pathPattern="/nfc/..*"
android:scheme="http" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.TECH_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:pathPattern="/nfc/..*"
android:scheme="http" />
</intent-filter>
<meta-data
android:name="android.nfc.action.TECH_DISCOVERED"
android:resource="@xml/nfc_tech_filter" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.example.com"
android:pathPattern="/nfc/..*"
android:scheme="http" />
</intent-filter>
我的技术文件是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<tech-list>
<tech>android.nfc.tech.NfcA</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcB</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcF</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcV</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.IsoDep</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.MifareClassic</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NdefFormatable</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.Ndef</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.NfcBarcode</tech>
</tech-list>
<tech-list>
<tech>android.nfc.tech.Ndef</tech>
<tech>android.nfc.tech.NfcA</tech>
<tech>android.nfc.tech.MifareUltralight</tech>
</tech-list>
</resources>
我也试过:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:pathPattern="\\/nfc/..*"
android:scheme="http" />
</intent-filter>
和:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:pathPattern="/nfc/.*"
android:scheme="http" />
</intent-filter>
甚至:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:scheme="http" />
</intent-filter>
和:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="www.example.com"
android:pathPrefix="/nfc"
android:scheme="http" />
</intent-filter>
如果有人有一些建议,如何使它工作或能给个解释为什么它是不可能的我们将不胜感激:)
我有一种感觉,问题可能在于你如何设置pathPattern
。
您试过android:pathPattern="\/nfc/.*"
了吗?
不错的尝试,但这个不工作太:(只是尝试过......我希望问题是在模式中,否则我坚持缺乏Android 6和7的功能 –
您是否已验证包含该URL的记录是否已正确写入您的标记?像字符集...... – corvairjo
是的,当我的活动打开它读取:http://www.example.com/nfc/NFC00000001但如果我的应用程序未打开,该应用程序不会单独启动。 PS的http协议是不可见的在*大声笑 –
我明白这一部分。我会验证(例如,使用NFC Taginfo应用程序)标签上的实际数据。 – corvairjo