Sergio
Sergio

Reputation: 655

onResume is not called when I relaunch the app after home button pressed

So I have my main activity, and when you press a button it launches activity2. Once activity2 is launched I press the home button and it will trigger onPause at activity2 and then the desktop of the android device comes to top. Everything's ok.

The problem is: now I click the app icon and instead of coming to top activity2 (the last active), it comes my main activity. So onResume is not called on activity2, but on my main activity.

Isn't it supposed to be called onResume on activity2? How could I make it work?

Upvotes: 3

Views: 1227

Answers (3)

Michael Dovoh
Michael Dovoh

Reputation: 121

Remove the android: launchMode="singleTask" from your launcher activity in the manifest file.

Upvotes: 0

Chris Stratton
Chris Stratton

Reputation: 40397

If you launch an application from the home screen launcher, you are specifically launching the activity which that launcher icon corresponds to.

The behavior you are thinking about is more along the lines of what occurs when you re-enter by way of an activity which is in the back stack.

If you want the home screen launcher icon to put you back in whatever activity you were previously in when that is different from the activity that icon is linked to, you'll need to keep track of that and have your launcher activity transfer you there.

Upvotes: 1

thoma
thoma

Reputation: 583

Just to be sure, didn't you override the onKeyDown method which is able to catch device buttons?

Upvotes: 0

Related Questions