Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to Activities/Services when phone goes to sleep/standby mode?

Tags:

android

What happens to android application and activities and services that belongs to application when the phone/AP goes to sleep mode?Will the framework destroy Activities and Services and OS kills the process?

like image 527
Suresh Avatar asked Nov 24 '10 14:11

Suresh


People also ask

What happens in sleep mode in phone?

Android's “Bedtime” mode, previously known as “Wind Down,” uses Do Not Disturb to silence calls, texts and notifications, while grayscale fades the colors on your phone to black and white, to reduce the draw to your screen.

What happens if you put an app to sleep?

Setting your apps to sleep will prevent them from running in the background so you can focus on the apps you use most often. You can always switch the settings later if you change your mind and need to start using a few apps again.

Why do apps prevent phone from sleeping?

Annoyingly, the root cause of this is frequently Android itself, trying to manage your phone's battery life by forcing "low" priority apps to go to sleep, with the end result being those delayed notifications.


1 Answers

In case of device sleep, activity's `onPause()' will be called. Read activity lifecycle to understand this.

OS only kills the process when memory/resources are low. Activities are killed first, services are only killed as last resort.

But there is no guarantee they will not be killed. This is why you should rely on system services to call you when you need some work done: use AlarmManager to do call your code periodically or use listeners to notify you of system changes (gps, network, etc..)

like image 77
Peter Knego Avatar answered Sep 18 '22 15:09

Peter Knego