DEV Community


Posted on


Android AsyncTask API deprecating in Android 11.What are the alternatives?

One of the simplest alternative is to use Thread

new Thread(new Runnable({
    public void run(){
       // do your stuff
       runOnUIThread(new Runnable({
          public void run(){
              // do onPostExecute stuff

If your project supports JAVA 8, you can use lambda

new Thread(() -> {
        // do background stuff here

Oldest comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.