0

I want to play audio on lock screen and I know for this I have to use service. But I am little confused So I have following questions.

  1. I want to know on home and back button press which method is called i.e. onPause or onStop?

  2. If my app running and someone call me and I pick the call then which method is called i.e. onPause or onStop?

  3. On screen lock which method is called?

Syed Waqas
  • 862
  • 2
  • 9
  • 29
John R
  • 2,078
  • 8
  • 35
  • 58

3 Answers3

2

first onPause() will be called for each of your question and onStop() will be called when another activity comes in foreground and your previous one goes in background.

The Basic difference is that when onStop() called the previous activity in not visible and new activity comes in foreground and overlap the previous one.

Irshad Khan
  • 794
  • 6
  • 21
1
  1. On home press: onPause->onStop. On back press: onBackPressed->onPause->onStop->onDestroy
  2. Same as pressing home essentially.
  3. Same as 2.
FD_
  • 12,947
  • 4
  • 35
  • 62
-2

Have a look at the documentation:

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Lifecycle

A.S.
  • 4,574
  • 3
  • 26
  • 43