I'm upgrading my app target SDK from API 30 to API 31. I have an ever-displayed notification during the execution of my app. This notification when clicked, opens the app if it is in background. The ContentIntent of my Notification triggers the execution of:
...
Intent myIntent = new Intent(context, MyActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(myIntent)
...
So,this code works as expected on my app that targets API 31 when executed on API 30 smartphone (the app goes foreground if it was in background). Instead, if running on API 31 smartphone, the app remains in background. I haven't found anything concerning e behavior change of this kind for apps that target api 31 on api 31 smartphone, so I'm wondering what should i do to put the app on foreground.
CodePudding user response:
Presumably, your existing code uses a "trampoline": a non-activity PendingIntent
that runs code that turns around and starts an activity. That is no longer supported. Instead, use an activity PendingIntent
that starts your MyActivity
directly.