Search code examples
androidonpauseandroid-homebutton

How to pause an activity on the emulator without stoping it


My question is almost similar to this question. In my app when I press the home button my app is stopped and not only paused. After reading the answers in the question (given in the link) I realized that onPause and onStop is indeed called after pressing the home button. So my question is how do I pause my activity on the emulator( there is no lock screen button) without stopping it or doing it programmitically.My logcat details are :

  06-24 05:43:29.011: D/My(1689): OnCreate
  06-24 05:43:29.011: D/My(1689): OnResume
  06-24 05:43:34.251: D/Sng[0](1689): /storage/sdcard/Music/05.Only you.mp3
  06-24 05:43:34.771: E/MediaPlayer(1689): Should have subtitle controller already set
  06-24 05:43:41.691: D/My(1689): OnPause
  06-24 05:43:48.081: D/My(1689): OnStop

Solution

  • Activity will be paused, for example, when dialog will appear. From Android Dev:

    When the system calls onPause() for your activity, it technically means your activity is still partially visible