DEV Community

Mayank Kumar Chaudhari
Mayank Kumar Chaudhari

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() {
    @Override
    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

Top comments (0)