Management Service Priority

I have an Android app that runs a background service that reads sensor data every second. I found out that if there are other applications, I do not collect my data every second (I have no seconds). I assume that the OS does not give me enough processor time.

Can I change the priority of a service among running tasks in order to get enough CPU and execute it?

(The service is called from the action using StartService(mIntentService).)

+3
source share
1 answer

The easiest way would be to use the startForeground () function, which notifies the system about how to use the service as a user that users know about, and can be paused or paused, so it will receive the same attention as running applications. You need to provide a notification object so that the user is informed about the running service.

+5
source

All Articles