How to set IntentService priority in Android

I was wondering if it is possible to set the IntentService priority as you can with Thread . So far I have not found anything.

+7
android multithreading service thread-priority
source share
4 answers

HandlerThread which IntentService does not use SDK. It is set to Process.THREAD_PRIORITY_DEFAULT as a priority.

Note that the IntentService is 143 lines of code, including spaces and comments, so you can just clone it with the priority you are looking for.

+6
source share

You can set Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND) in the onHandleIntent() method of your intent service.

CommonsWare solution also works. However, this is easier.

+12
source share

Just to make it clear - the default IntentService default priority is Process.THREAD_PRIORITY_DEFAULT because it uses HandlerThread Internally. You can use Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND) in OnHandleIntent () or whatever CommonsWare suggested in response.

some people raised this as a mistake . and patch is available for this.

0
source share

I changed the priority of the IntentService using: "Android.os.Process.setThreadPriority (android.os.Process.THREAD_PRIORITY_BACKGROUND);" in the constructor of the IntentService class.

In my case, this was changed from: "Process.THREAD_PRIORITY_DEFAULT", which is zero (0) - "Process.THREAD_PRIORITY_BACKGROUND", which is ten (10), and the result was visible.

-4
source share

All Articles