Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent.FLAG_ACTIVITY_REORDER_TO_FRONT not working in android 11

I need to bring the app from background to foreground when push notifications arrives. This code works fine on versions prior to 11.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    ...
    Intent intent = new Intent(this, MainActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                    startActivity(intent);
    ...
}

But stops working in android 11. Any idea? Thanks!!

like image 956
Aramillo Avatar asked Sep 06 '25 03:09

Aramillo


1 Answers

Posting comment as answer:

AFAIK, Its not possible to start activities from the background since Android 10 unless your app meets one of the specific exceptions, see here. Are you sure your app was in the background? Also Intent.FLAG_ACTIVITY_REORDER_TO_FRONT should have nothing to do with actually starting the activity, it just moves to it the front of the stack if it is already running.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!