I tried to go through the documentation the android provides about AsyncTask, even though it's a bit too much to comprehend, but what I came across is Threading rules for AsyncTask to work properly.
I paste the link here; https://developer.android.com/reference/android/os/AsyncTask.html#threading-rules
Here are the rules;
There are a few threading rules that must be followed for this class to work properly:
The AsyncTask class must be loaded on the UI thread. This is done automatically as of Build.VERSION_CODES.JELLY_BEAN.
The task instance must be created on the UI thread.
execute(Params...) must be invoked on the UI thread.
Do not call onPreExecute(), onPostExecute(Result), doInBackground(Params...), onProgressUpdate(Progress...) manually.
The task can be executed only once (an exception will be thrown if a second execution i is attempted.)
I understand the rule 2, 3, and 4 also.
What I don't understand is the rule 1 and 5.
The class that extends AsyncTask is the instance created on the UI thread (for example onCreate()) - rule 2
What they are trying to say in rule 1?
How it is loaded automatically without we ever mention it?
As of rule 5, are they saying, a single instance of the class that extends AsyncTask can be executed once, if we want to execute one more time, do we have to create another instance of the same class?
Thanks