What is the difference between a background and foreground service?

后端 未结 3 460
予麋鹿
予麋鹿 2020-12-13 17:27

I am currently writing my first Android application and I keep running into references to background and foreground services. Since I intend on using a service in my applica

3条回答
  •  死守一世寂寞
    2020-12-13 17:51

    Foreground: The process relies on onPause() and onResume()...i.e you play music player and pressing pause and play

    Background: The process which runs without user interaction i.e receiving a message, incoming call, receiving mails, or setting alarms. The method used here is onStart() and onStop().

    For example, check it on your phone. Create an alarm at 6:30am. When the system clock reaches 6:30am it fires. In order to kill the alarm service, just go to menu-->settings-->application-->Running service-->click stop service. It stops the alarm service even when your system reaches the time it won't fire.

提交回复
热议问题