DEV Community

Mayank
Mayank

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
          }
       })
    })).start();

If your project supports JAVA 8, you can use lambda

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

Latest comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git