Android Question Main activity it's killed when firing a new activity from onResume to catch a Notification

Luiz Orlandini

Member
Licensed User
Hi there!

My requirement: When receive a new push message, needs to identify which kind of message I received (data tag) and redirect the user to a different activity then Main (I have like 7 different activities that will be thrown depending on the notification received).

So I'm sending a push notification to my App, using both tags: data and notification.

When my App is in background I'm having a weird issue.

I catch the extra's Intent on onResume, to identify which Activity I should redirect. That's works like a charm. Although when I use CallSub2(Activity, "Method", Parameter), the activity is shown and Main is killed. And after that starts some kind of loop, trying to re-launch Main activity/Activity from push.

Ay ideas on how I can solve this? Catch the notification when the App is in background and when the user clicks on it route him to the correct Activity.

Cheers.
 

Luiz Orlandini

Member
Licensed User
You can start the correct activity directly from the push notification event in the service.
You mean from FirebaseMessaging Service?

If so, that not possible.

When we do have in the message payload the tags DATA and NOTIFICATION, and the app is running in the background mode, the fm_MessageArrived method won't be fired. I did a bunch of different tests and no luck at all.

This is the exact behavior I have: https://www.b4x.com/android/forum/t...d-background-data-notification.73356/#content. See 1st post from @KMatle
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

KMatle

Expert
Licensed User
Longtime User
the app is running in the background mode

Forget my first post (who is tired should not post anything :) )

Which device and OS? (Check energy savings: app must be allowed to run in the background! Otherwise it will be stopped immediately when the screen turns off. Believe me: It took me hours to get behind that)
 
Upvote 0

Luiz Orlandini

Member
Licensed User
haha not a problem at all :)

I'm testing in a Samsung J6, OS 6.0.1.

This is the first time I heard about allow an app to run in the background. Any clue on how to enable that in a programatic way?

Cheers.
 
Upvote 0
Top