1

嘿StackOverflowers ...NDEF意圖過濾器不會在Android中6啓動應用程序,7

我支持具有NFC讀取功能,它需要通過掃描NFC標籤,打開該應用程序的應用程序。它適用於4.3和所有4.X版本android.nfc.action.NDEF_DISCOVEREDintent-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> 

如果有人有一些建議,如何使它工作或能給個解釋爲什麼它是不可能的我們將不勝感激:)

+0

您是否已驗證包含該URL的記錄是否已正確寫入您的標記?像字符集...... – corvairjo

+0

是的,當我的活動打開它讀取:http://www.example.com/nfc/NFC00000001但如果我的應用程序未打開,該應用程序不會單獨啓動。 PS的http協議是不可見的在stackoverflow大聲笑 –

+0

我明白這一部分。我會驗證(例如,使用NFC Taginfo應用程序)標籤上的實際數據。 – corvairjo

回答

0

我有一種感覺,問題可能在於你如何設置pathPattern

您試過android:pathPattern="\/nfc/.*"了嗎?

http://bluefletch.com/blog/android-nfc-reading-tags/

+0

不錯的嘗試,但這個不工作太:(只是嘗試過......我希望問題是在模式中,否則我堅持缺乏Android 6和7的功能 –

相關問題