Joshua Augustinus
Joshua Augustinus

Reputation: 1670

Can no longer launch app from FirebaseMessagingService after Android OS update

Inside my FirebaseMessagingService I have something like:

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
                Log.d(TAG, "Launching app");
                Intent i = new Intent(getBaseContext(), MainActivity.class);
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                i.putExtra(EXTRA_MESSAGE,remoteMessage);
                startActivity(i);
    }

When I send a FCM message when the app is closed I can see the log "Launching app". However, the app doesn't launch. This bug only happened recently after I updated the OS on my tablet.

I tested my app on another Android device that wasn't udpated recently and it works. Any ideas?

Upvotes: 0

Views: 404

Answers (1)

Maulik Togadiya
Maulik Togadiya

Reputation: 591

Yes this is because Android has restricted opening activity from background after Android 10 but it might works web your app is open but strictly not work if it is in background .check out this: https://developer.android.com/guide/components/activities/background-starts

Upvotes: 2

Related Questions