2

I have some troubles with this warning in Android Studio in one of my java classes. Default constructor in android.os.AsyncTask is deprecated.. I use latest target SDK.

public CleanFilesTask(@NonNull Context context, @NonNull Consumer < Integer > callback) {
        Objects.requireNonNull(context);
        mContentResolver = context.getContentResolver();
        mCallback = Objects.requireNonNull(callback);
    }

How to solve this warning and make it not showing deprecated? XD

Link for full class: https://github.com/D4rK7355608/com.d4rk.cleaner/blob/master/app/src/main/java/com/d4rk/cleaner/invalid/task/CleanFilesTask.java

D4rK
  • 329
  • 4
  • 12
  • You forgot to ask an actual question. – Turing85 Aug 22 '21 at 19:00
  • Thanks XD I want it to make it not showing that "deprecated" without disable inspection in settings. I tried to search on Android Developers and didn't find any solution XD – D4rK Aug 22 '21 at 19:03
  • 2
    From the [`AsyncTask` documentation](https://developer.android.com/reference/android/os/AsyncTask): "*This class was deprecated in API level 30. Use the standard java.util.concurrent or Kotlin concurrency utilities instead.*" – Turing85 Aug 22 '21 at 19:05
  • Ahh, didn't noticed this. Thanks so much! – D4rK Aug 22 '21 at 19:06

1 Answers1

2

according to google doc:

This class was deprecated in API level 30. Use the standard java.util.concurrent or Kotlin concurrency utilities instead.

you can check concurrent tutorial on this link,

and how to migrate from AsyncTask to concurrent here

Iman Dolatkia
  • 186
  • 1
  • 7