1

Hé là StackOverflowers ...filtre l'intention NDEF ne démarre pas application dans Android 6 et 7

Je soutiens une application qui ont NFC lire des fonctionnalités et il a besoin d'ouvrir l'application en scannant un tag NFC. Il fonctionne bien sur 4.3 et toutes les versions 4.X android.nfc.action.NDEF_DISCOVEREDintent-filter.

Ainsi, l'URL est comme ceci: http://www.example.com/nfc/NFC00000001

et j'ai lu presque tous les possibles réponses connexes sur filtre l'intention NFC.

Je suis capable d'aller chercher une étiquette NFC via le code si l'activité est ouverte mais ce n'est pas ce dont j'ai besoin.

Les applications de lecteur NFC montrent que mon tag est

NXP MIFARE Ultralight (Ultraléger C) - NTAG213

Et qu'il soutient

NFCA, MifareUltralight, Ndef

Ne fonctionne pas sur Android 6 (Nexus 4), Android 6 (OnePlus 3) et Andorid 7.1.1 (Nexus 6P). Je n'ai pas d'autres appareils Android 6 et 7, donc je ne peux pas tester sur Android 5.

J'ai essayé avec et sans android.nfc.action.TECH_DISCOVERED

J'ai essayé presque toutes les options possibles et ceci est mon approche finale qui ne fonctionne pas trop (l'application ne sera pas lancée).

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

Mon fichier technologies est comme ceci:

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

J'ai aussi essayé:

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

Et:

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

Et même:

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

Et:

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

Si quelqu'un a des conseils comment le faire fonctionner ou donner des explications pourquoi il est pas possible, il serait apprécié :)

+0

Avez-vous vérifié que le dossier avec l'URL est écrit correctement à votre tag? Des choses comme le jeu de caractères ... – corvairjo

+0

Oui, lorsque mon activité est ouverte, elle se lit comme suit: http://www.example.com/nfc/NFC00000001 mais l'application ne se lance pas seule si mon application n'est pas ouverte. PS le protocole http n'est pas visible dans le stackoverflow lol –

+0

J'ai compris cette partie. Je vérifierais (par exemple avec l'application NFC Taginfo) quelles données sont réellement sur l'étiquette. – corvairjo

Répondre

0

J'ai le sentiment que le problème réside peut-être dans la façon dont vous définissez votre pathPattern. Avez-vous déjà essayé android:pathPattern="\/nfc/.*"?

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

+0

bien essayer mais celui-ci ne fonctionne pas trop :(juste essayé que ... J'espère que le problème est dans le modèle ou sinon je suis coincé avec le manque de fonctionnalités pour Android 6 et 7 –