I have a AsyncTask class that is separate from the MainActivity.
protected void onPostExecute(ArrayList<String> result) {
System.out.println("flag1");
MainActivity.myLst=new ArrayList<String>();
MainActivity.myLst=result;
}
then I have the following code in my MainActivity.
public void onCreate(Bundle savedInstanceState) {
new AsyncTask().execute();
System.out.println("flag2");
System.out.println(myLst.size());
}
The program outputs the flag2 first and myLst.size is 0. If I negative to other activity and then come back to the main activity and myList.size has the correct size. I thought It should output everything and do the work in AsyncTask before the MainActivity.