Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the priority of android service?

Is there any way to set the priority of android service? I want to run the service in background after destroying App's main actvity. So i am returning "START_REDELIVERY_INTENT" from my service. But restarting of service is taking some time (around 1-3 minutes). I want to restart the service instantly. Is there any way to set the priority of android service.

FYI, I am creating service using startService and passing an object through intent.putExtra().

Below snapshot is taken from setting/apps/running apps by my android device, which shows that app is restarting... My app is real time specific, so i want to restart it instantly...

enter image description here

like image 909
doga Avatar asked Jan 24 '26 04:01

doga


1 Answers

You cannot control this behavior of Service as it depends on the OS and available resources. However, for a continuously running background service, I would suggest you to return START_STICKY - which tries its best to re-run the service once its destroyed due to any reasons.

like image 132
waqaslam Avatar answered Jan 25 '26 17:01

waqaslam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!