I discovered that when I put the Nexus S (running Android 2.3.6) next to a NFC tag which contains an NDEF message with an URI-record pointing to a web-site, this will cause (as expected) that the NFC activity chooser is shown (as I have several NFC reader apps installed, and I’m working on my own application that also intercepts detected NFC tags).
However, using the Galaxy Nexus (Android v4, Ice Cream Sandwich), the activity chooser does NOT appear. It will simply directly launch the browser. LogCat will show this:
D/NfcService(438): TAG: Tech [android.nfc.tech.MifareUltralight, android.nfc.tech.NfcA, android.nfc.tech.Ndef]
I/ActivityManager(196): START {flg=0x10008000 cmp=com.android.nfc3/com.android.nfc.NfcRootActivity (has extras)} from pid 438
I/ActivityManager(196): START {act=android.nfc.action.NDEF_DISCOVERED dat=http://www.someURL.com/someotherstuff cmp=com.google.android.browser/com.android.browser.BrowserActivity (has extras)} from pid 438
So this gives me two questions:
a) Android 2.3.6 and 4.x decide to behave differently, becaaaause…?
b) Even when I try to restrict my application to match only NFC tags that contain the http://www.someURL.com host, i.e. by putting
<data
android:host="www.someURL.com"
android:pathPattern="/*"
android:scheme="http" />
into my 3 intent-filters (one for TAG_DISCOVERED, one for TECH_DISCOVERED, one for NDEF_DISCOVERED, I really tries to grab the NFC activity chooser’s attention there..), the result won’t change. It will just open the browser. ATM the only thing that works is Foreground-dispatching…
Any ideas?
You should probably use “android:pathPrefix” instead of “android:pathPattern”. You are now matching 0 or more occurrences of “/”…