Search code examples
javaandroidandroid-activitybackground-process

Java - android - change activity of app while running in the background


I'm developing an Android app with several types of alarms and triggers. One of these alarms trigger if you stop moving (GPS tracking) while it's active.

Now, when the app runs in the background when this triggers the client doesn't update when you switch back in, and the only notification received is a push-notification from the backend service. If I enter through the notification, the client loads the alarm correctly.

The code base is quite extensive, and due to time and resources it would be best to avoid huge refactoring tasks. Is there an easy way to make the app go from Activity A to Activity B when it's running in the background?


Solution

  • You cannot change the current Activity in the background without bringing the app to the foreground (using startActivity()). However, you can surely tell the app that when it is brought to the foreground it should start a certain Activity or rearrange the back stack or whatever.

    Post some of the code and maybe we can help more.