Question

I'm trying to implement Android Beam in an app that will not be distributed through Market. There is a one-to-one correspondence between my app's activities and pages in a particular web page. The behavior I would like is for it to attempt to open my app, and if it is not installed to go to the corresponding web page. The app already has IntentFilters to handle the ACTION_VIEW for those URLs, and I'd like to leverage that. I already tried using NdefRecord.createUri(String uriString), but it always opens the stock Android browser (It won't even go to alternative browsers if installed).

In the onCreate() of my Activity:

NdefMessage msg = new NdefMessage(new NdefRecord[] { NdefRecord.createUri(getAppUri()) });
NfcAdapter.getDefaultAdapter(this).setNdefPushMessage(msg, this);
Was it helpful?

Solution

Android Beam Intents have the action set to ACTION_NDEF_DISCOVERED (not ACTION_VIEW), so you should filter for that instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top