3
votes

I followed instructions to setup NFC to launch my app on Android. The first record in the tag is a url to my website. ex. example.com

The AndroidManifest.xml file has the following intent filter:

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED" />
    <data android:host="example.com" android:scheme="http" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

But for whatever reason when I scan the tags, the android browser opens, not my app. Android documentation for nfc doesn't appear to have any additional steps https://developer.android.com/guide/topics/connectivity/nfc/nfc.html

For what it's worth, I'm using Apache Cordova and the phonegap-nfc plugin.

1

1 Answers

6
votes

Your intent filter looks good and works a sample app I wrote. I get prompted to open the tag with my app or Chrome.

Android prompts for app open

I expect at one point you told Chrome to open http://example.com tags or all URL tags and now Chrome grabs the intent before your app can launch.

If fixed this by resetting all app preferences. Settings -> Device -> Apps -> Menu -> "Reset App Preferences" See https://support.google.com/nexus/answer/6271667?hl=en

After resetting the preference Android prompted me again to choose an app when I scanned the tag. I chose complete action using NFCLaunch (my app) always. Now tags with http://example.com open my app but other tags with http://android.com will still open in Chrome.

Another option is to: disable Chrome, scan the tag, choose the app, re-enable Chrome.