Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is START_STICKY,START_NOT_STICKY and START_REDELIVER_INTENT Service

I am unable to understand

  1. START_STICKY,
  2. START_NOT_STICKY and
  3. START_REDELIVER_INTENT

Can anyone explain clearly with examples.

I went through this link but couldn't understand it clearly.

like image 285
Kittu Rajan Avatar asked Dec 27 '12 12:12

Kittu Rajan


People also ask

What is Start_sticky and Start_redeliver_intent?

START_STICKY- It will tell the system to create a newest copy of the service, when available memory is sufficient to do, after it retains state and recovers from the low memory. In this process we will loose the results that might have calculated before.

What is the difference between Start_sticky Start_not_sticky and Start_redeliver_intent?

START_NOT_STICKY- tells the system not to bother to restart the service, even when it has sufficient memory. START_REDELIVER_INTENT- tells the system to restart the service after the crash and also redeliver the intents that were present at the time of crash.

What is sticky and non sticky service?

START_STICKY tells the OS to recreate the service after it has enough memory and call onStartCommand() again with a null intent. START_NOT_STICKY tells the OS to not bother recreating the service again.

What is the difference between sticky non sticky and redeliver intent?

According to how services stick to your application Non-sticky Redeliver-Intent services — it is same as non sticky content but the only difference is it will re-deliver the same intent until it completes.


1 Answers

These are related to services. We all know that services keeps on running in the background and they also consume some memory to execute.

So, as more of the application runs on android device, the device memory keeps on getting low and when the time arises, when the device memory gets critically low, the android system starts terminating processes, so as to release the memory occupied by the processes.

But you might be doing some important task with the services, that could also get terminated as the service stops. so these concepts are to tell the android system what action you want to perform when the device memory gets stable and when it is ready to relaunch the services.

The simplest explanation of these could be,

START_STICKY- tells the system to create a fresh copy of the service, when sufficient memory is available, after it recovers from low memory. Here you will lose the results that might have computed before.

START_NOT_STICKY- tells the system not to bother to restart the service, even when it has sufficient memory.

START_REDELIVER_INTENT- tells the system to restart the service after the crash and also redeliver the intents that were present at the time of crash.

like image 53
Sahil Mahajan Mj Avatar answered Sep 27 '22 21:09

Sahil Mahajan Mj