Q:

Is there a way to resume an application to the "current activity" even if it was killed by the OS?

I am working on a taxi application like Uber. I have a background service that keeps the app working in the background. When the driver starts the trip, the app reloads to the homepage instead of staying at the JourneyActivity(this happens if the trip takes 10 minutes or more). How can I ensure that even if the app is killed, when the driver opens it again it takes them to the JourneyActivity?
Any help would be highly appreciated. Thanks

A:

You can use PendingIntent over a notification which you can keep displaying while the service is running in the background. With this, whenever a user clicks on the notification, he will be taken to the JourneyActivity. For cases when the app icon is clicked, you can implement using SharedPreferences whenever you have a running Journey. Set a flag value to 1. In the onCreate method of the LauncherActivity, check for this value, and if it is 1, you can directly launch the JourneyActivity, otherwise, continue with the LanucherActivity.
Please note, You will have to reset this flag to 0 once the Journey Ends.

