0

I have started a service in foreground using startForeground with some notification. This call is made on Activity1.
Suppose that I am now in Activity2. Tapping the notification would launch Activity1 instead of the last activity Activity2.
How to make tapping a notification restore the last active activity ?

MMasmoudi
  • 508
  • 1
  • 5
  • 19

1 Answers1

0

I was inspired by the nRF Connect app to solve this issue.
I noticed that the notification appears only when the app is put in background. It means that the startForeground method should be called when the app goes into background and the stopForeground should be called in the activity's onResume. Thus, each activity should handle this logic independantly.

MMasmoudi
  • 508
  • 1
  • 5
  • 19