While reading the documentation, I found that The AsyncTask class must be loaded on the UI thread. But I am surprised that AsyncTask can also be executed from the worker thread.
So the question is:
If AsyncTask can also execute from the background thread, Why in the documentation they are saying just opposite to it.
How could it possible to have context on onPostExecute.?
new Thread(new Runnable() { @Override public void run() { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); Toast.makeText(getBaseContext(), "in AsyncTask...", Toast.LENGTH_SHORT).show(); } }.execute(); } }).start();