Domanda

android developer guide says

Activities should register the most specific intent filters possible to avoid the activity chooser dialog, which can disrupt the interaction with the tag as the user interacts with the screen.

I'm developing an app that should pick up just his type of MIME and it is really important that no Activity chooser will be displayed, but I'm wondering: what happens if in the same device there is a generic NFC reader app? Will the Activity chooser be displayed or will my app just start?

È stato utile?

Soluzione

The app with the most specific intent filter that matches the NDEF data will win. So if you register for a record with MIME type text/plain and another activity registered for just any NDEF data (android.nfc.action.NDEF_DISCOVERED without any data specification), your activity will automatically be shown.

Note, however, that if one activity registers for NDEF_DISCOVERED + MIME type text/plain and a second activity registers for NDEF_DISCOVERED + MIME type text/*, both intent filters will be considered equal and an activity chooser will be shown.

In general you might want to prefer NFC Forum external types over MIME types as those types permit you to specify a unique domain for your record types.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top