Android Asynctask on PreExecute method not called
11,028
Solution 1
Chnge your onPreExecute
method as:
@Override
protected void onPreExecute()
{
progresdialoglistview=ProgressDialog.show(HomeActivity.this, "","Loading");
Log.e("onPreExecutive","called"+progresdialoglistview);
}
onPreExecute() method don't take any parameter and have void return type . so also remove return from onPreExecute
Solution 2
You didn't overrided onPreExecute
but overloaded instead.
onPreExecute
doesn't takes any params and do not return anything. Use this instead:
protected void onPreExecute()
Author by
Mahesh
Updated on June 04, 2022Comments
-
Mahesh almost 2 years
I want to start a
ProgressDialog
whenonPreExecute()
is called but it is not working.Homeactivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //switch condtion... case R.id.buttontime : new FlightListTask().execute(""); break: } public class FlightListTask extends AsyncTask<String,ArrayList<HashMap<String, String>>, ArrayList<HashMap<String, String>>> { protected String onPreExecute(String temp) { progresdialoglistview=ProgressDialog.show(HomeActivity.this, "", "Loading"); Log.e("onPreExecutive","called"+progresdialoglistview); return temp; } @Override protected ArrayList<HashMap<String, String>> doInBackground( String... params ) { return flightlist; } protected void onPostExecute(ArrayList<HashMap<String, String>> flightList) { // listview code.... } }