Google is deprecating Android AsyncTask API in Android 11 and suggesting to use java.util.concurrent instead. you can check out the commit here
* * @deprecated Use the standardjava.util.concurrentor * * Kotlin concurrency utilities instead. */ @Deprecated public abstract class AsyncTask{
If you’re maintaining an older codebase with asynchronous tasks in Android, you’re likely going to have to change it in future. My question is that what should be proper replacement of the code snippet shown below using java.util.concurrent. It is a static inner class of an Activity. I am looking for something that will work with minSdkVersion 16
private static class LongRunningTask extends AsyncTask{ private static final String TAG = MyActivity.LongRunningTask.class.getSimpleName(); private WeakReference activityReference; LongRunningTask(MyActivity context) { activityReference = new WeakReference(context); } @Override protected MyPojo doInBackground(String... params) { // Some long running task } @Override protected void onPostExecute(MyPojo data) { MyActivity activity = activityReference.get(); activity.progressBar.setVisibility(View.GONE); populateData(activity, data) ; } }
0 answers
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20524
7
13634
4






