Android Question Application is taken to Foreground when Firebase message arrives

soltypio

Member
Licensed User
Longtime User
My app receives push notifications sent using php code on the server.

It happens sometimes, that main activity is taken to Foreground when FCM message arrives.

Activity Main is previously open from starter service using:
StarActivity(Main) from Service_Start,
and then closed using Activity.Finish somewhere in Main Activity code.

My fm_MessageArrived Sub is exactly as in Erels Firebase Messaging tutorial.

I do not want activity to start when push arrives. Any idea what am I doing wrong?
Is it because Starter Service is killed and recreated by OS when message arrives, and then Service_Start is called again?
 

DonManfred

Expert
Licensed User
Longtime User
Activity Main is previously open from starter service using:
StarActivity(Main) from Service_Start
You should not start main activity from the starter
 
Upvote 0

soltypio

Member
Licensed User
Longtime User
Thank You!
Somehow I assumed that I should start main activity form starter, and didn't even bother to test if it starts itself. I am reading tutorials not carefully enough...

I have also moved initialization of some global variables and Firebase Messaging object from Service_start to Service_Create, after reading tutorials more carefully. I guess this is was also a mistake.

Again, Thanks for Your help!
 
Upvote 0
Top