1、AsyncTask替代方案
- @deprecated Use the standard <code>java.util.concurrent</code> or
- <a >
- Kotlin concurrency utilities</a> instead.
*/
@Deprecated
public abstract class AsyncTask<Params, Progress, Result> {
【協(xié)程替代方案】如下:
val job = lifecycleScope.launch {
val data = async(Dispatchers.IO) {
try {
//耗時(shí)操作
return@async null
} finally {
}
}
withContext(Dispatchers.Main) {
val result = data.await()
result?.apply {
}
}
}
2喘落、AsyncTaskLoader 替代方案
@deprecated Use the <a href="{@docRoot}tools/extras/support-library.html">Support Library</a>
*/
public abstract class [AsyncTaskLoader]
This class was deprecated in API level 28.
Use the Support Library android.support.v4.content.AsyncTaskLoader
3趟章、IntentService
This class was deprecated in API level 30.
IntentService is subject to all the background execution limits imposed with Android 8.0 (API level 26). Consider using [WorkManager](https://developer.android.com/reference/androidx/work/WorkManager.html)
or [JobIntentService](https://developer.android.com/reference/androidx/core/app/JobIntentService.html)
, which uses jobs instead of services when running on Android 8.0 or higher.