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 ?
Asked
Active
Viewed 56 times
0

MMasmoudi
- 508
- 1
- 5
- 19
-
refer this https://stackoverflow.com/questions/9188412/how-to-open-last-activity-from-notification-status-bar?answertab=votes#tab-top – Dec 05 '18 at 10:06
-
Sorry, didn't work – MMasmoudi Dec 05 '18 at 12:48
-
I would call startForeground again from the second activity with the updated notification from Activity2. – Nicola Gallazzi Dec 05 '18 at 13:51
1 Answers
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