Peter
Peter

Reputation: 919

Detecting when application becoming active coming from background

When my application comes back from background, it goes to the last activity (screen).
I would like it to go to the home screen instead - How I can accomplish that?
Or, how to detect event when whole application (not activity) comes from background to the front?

Upvotes: 0

Views: 2285

Answers (3)

ethrbunny
ethrbunny

Reputation: 10469

If you are building off of 'runnable' you can override onPause and onResume.

Upvotes: 3

Rohit Mandiwal
Rohit Mandiwal

Reputation: 10462

You can try out to call finish() on the onPause() method of that activity which is restoring on getting the application to foreground. This will finish that activity and now your home activity will be on top in the Activity Stack and displayed first on restore to foreground.

Upvotes: 0

bigstones
bigstones

Reputation: 15257

Changing normal task's "stack" behavior is possible in many ways, but it's quite not simple. Some options are achievable with startActivity() flags, some others through properties of the manifest's <activity> element. Some are available in both ways, some not. Some work only if combined with others, some change behavior if combined with others. I feel really confused with these features.

Luckily this simple option might be what you're interested in.

Upvotes: 1

Related Questions