Search code examples
androidandroid-asynctask

How to elevate the priority of AsyncTask?


Is there a way to elevate the priority of an AsyncTask?

I'm doing some image manipulation in an AsyncTask. On a very slow device, it takes up to 60 seconds to process an image. Now I'd like to increase the performance by elevating the priority of the task. Can it be done somehow?


Solution

  • Try to use following (increase of priority AsyncTask threads):

    protected final MyResult doInBackground(MyInput... myInput) {
        Process.setThreadPriority(THREAD_PRIORITY_BACKGROUND + THREAD_PRIORITY_MORE_FAVORABLE);
        // blah-blah
    }