startActivity from FirebaseMessagingService.onMessageReceived is not work on several devices

0

Push-message is coming, but startActivity don't work on some devices. Lsat what i see in log file is:

intent: Intent { flg=0x10000000 cmp=com.name.name/.Activity.MyActivity (has extras) }

The problem is seen on several devices with API 27 and 23, but all other devices work's good.

I managed to reproduce this problem on the API 29 emulator, but only if the application is unloaded from memory. On all other API 24-28 emulators, this code works without problems.

It's my FirebaseMessagingService class:

public class MyFirebaseMessagingServiceTest extends FirebaseMessagingService {
    // Get push-message.
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        logger.trace("MyFirebaseMessagingServiceTest.onMessageReceived()");

        // Get data.
        Map<String, String> data = remoteMessage.getData();
        logger.trace("data: {}", data);
        // If data is not empty.
        if (remoteMessage.getData().size() > 0) {
            logger.trace("remoteMessage.getData().size() > 0");
            // Run activity.
            Intent intent = new Intent(getApplicationContext(), MyActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.putExtra("data", "data");
            logger.trace("intent: {}", intent);

            try {
                startActivity(intent);
            } catch (Exception exception) {
                logger.error("Exception", exception);
            }
        }
    }
}

It's my AndroidManifest.xml file:

<service android:name=".Core.MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
    </intent-filter>
</service>

Any help please?

android
asked on Stack Overflow Nov 19, 2019 by spice0xff

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0