Is there an equivalence of 'android.os.AsyncTask' in java or I just use 'Thread#sleep'?
-
21-12-2019 - |
Question
I am trying to develop an application that is already exist but for android OS. I faced a class that extends android.os.AsyncTask<Void, Void, Void>
, because java does not have this class.
What I want is to do some functions in the background like this class do I think. So is there a thread or any class for that purpose or I just use Thread.sleep()
method?
Solution
It would be wise to make your own Thread as a backgroundTask
like in android's AsyncTask
.
sample:
Thread d = new Thread(new Runnable() {
@Override
public void run() {
//do background task here
}
});
d.start(); //start the background task
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow