Search code examples
androidserviceonpause

Confusion in understanding methods in android


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?


Solution

    1. On home press: onPause->onStop. On back press: onBackPressed->onPause->onStop->onDestroy
    2. Same as pressing home essentially.
    3. Same as 2.