0

I am developing a custom launcher/home-screen, thus I am able to hand home-press events.

Sometimes I want it to intercept Home-presses without affecting the visible activity-stack so to speak. When I press home, however, I get to the launcher stack I suppose, but what I want to do then is get back to the last visited activity stack that was shown right before I pressed home. How can I do that?

How can I retrieve and show the activity that was visible right before I pressed home?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JohnyTex
  • 3,323
  • 5
  • 29
  • 52
  • Possible duplicate: http://stackoverflow.com/questions/4783960/call-method-when-home-button-pressed-on-android – Ricardo Apr 18 '16 at 12:37
  • I can intercept home in onResume(). Though at that point I want to exit that launcher activity immediately and return to the previous activity. – JohnyTex Apr 18 '16 at 12:40
  • I'd say you could keep a tracking of the the previous activity in the current activity and start it onResume – Ricardo Apr 18 '16 at 12:47
  • In onResume(), how can I know which was the previous activity? – JohnyTex Apr 18 '16 at 12:48
  • http://stackoverflow.com/questions/4038479/android-go-back-to-previous-activity – Ricardo Apr 18 '16 at 12:52
  • I don't think this is what I want because I am traversing across different apps. Not only my internal activity stack. – JohnyTex Apr 18 '16 at 12:56
  • What actually happens if I call finish() in a Launcher-app? – JohnyTex Apr 18 '16 at 13:41
  • If you have no other activity running it will send the app to background. If, for example, you are in the Main activity, you navigate to your second activity, and you call finish() in the second activity you will go back to the main activity – Ricardo Apr 18 '16 at 13:49
  • But when I am in main and do finish() in onResume I get empty black screen. I never go back to any other previous activity stack belonging to some other app. Why? – JohnyTex Apr 18 '16 at 13:50
  • onResume works similarly like onCreate so if you call finish() in it you will close the activity – Ricardo Apr 18 '16 at 13:52
  • Yes it will close, but then where do I go if launcher (home-screen) closes? – JohnyTex Apr 18 '16 at 13:53

0 Answers0