0

My app receives FCM message and sends a local notification. When the app is running with other activities on top of the MainActivity, I don't want the notification to start a new MainActivity or bring it to the foreground. I need it to stay at bottom of the stack, check the data in the local notification and show a dialog to the user. Is there any way to do this?

Or, any way to make whatever the activity on top of the stack to handle the local notification?

Surya Prakash Kushawah
  • 3,185
  • 1
  • 22
  • 42
jarly
  • 231
  • 1
  • 4
  • 16

2 Answers2

0

Well you can achieve this by creating a base activity, which you will inherit in all of your application's activities. When you receive an event, you simply check if the activity that is at the top of the stack is an instance of your base activity or not. If it is, you can create a dialog in the base activity with the data that you received in the event. Hope it helps.

Community
  • 1
  • 1
Vinil Narang
  • 663
  • 6
  • 11
0

I sent a broadcast to my app instead of starting activity when local notification is clicked. The broadcast receiver checks for the top activity and performs some tasks accordingly.

jarly
  • 231
  • 1
  • 4
  • 16