java – Using the original AsyncTask with LibGDX

Question:

I want to use AsyncTask from android.os package. Yes, I know there is a custom AsyncTask from the com.badlogic.utils package, but I need the first one. So I imported this:

import android.os.AsyncTask;

SDK used: Android 20 API Platform.

And when I run I get errors:

Error:(4, 18) error: package android.os does not exist
Error:(146, 38) error: cannot find symbol class AsyncTask
Error:(30, 26) error: cannot find symbol method execute()
Error:(148, 9) error: method does not override or implement a method from a supertype

And this applies not only to AsyncTask, I have not found an adequate explanation of how you can use the "native" classes for Android. Appreciate.

Answer:

As it turns out, there is no way to access the Android API from the core module. This module is used for all platforms.

But there is a way to get around this – using interfaces, you can access the platform's capabilities.

Scroll to Top