Use my application for NFC payment when not set as default Use my application for NFC payment when not set as default android android

Use my application for NFC payment when not set as default


So I finally found a solution!

You have to use setPreferredService(Activity, ComponentName) in your current foreground activity. It is recommended to to call it inside onResume() and also do not forget to call unsetPreferredService(Activity) once the activity is not in foreground (onPause() is good place to call it).

One more thing: setPreferredService(Activity, ComponentName) and unsetPreferredService(Activity) were added in API 21, so be sure not to call them from older API.