Search code examples
javaandroidandroid-activitybackgroundandroid-10.0

Android Q - Privacy change activity start through NFC


https://developer.android.com/preview/privacy/background-activity-starts

From this, it results that my payment app, which shows an Activity when a NFC transaction is performed, will not be able anymore to show anything to the user.

Has anyone have a clue what would be the new approach ?

Thanks!

I currently use the NFC service and it starts an Activity intent.

Intent intent = new Intent(mApplicationContext, PaymentActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
mApplicationContext.startActivity(intent);

The Activity should be shown. It works now, but from Android Q, it won't


Solution

  • According to the link, if you are having a HostApduService, then your app should work the same in Android Q.

    If that is not your case, the simplest work around is to get "Draw over other apps" permissions. You can open activities if the app has been granted the SYSTEM_ALERT_WINDOW permission by the user. I have tested this and working.

    Technically, you are showing something on top of other apps without user's interaction, so this might be the right way to go.