Try this:
class myAsyncTask extends AsyncTask<Void, Void, Void> {
Context context;
myAsyncTask(Context context) {
this.context=context;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
//Do stuff that you want after completion of background task and also dismiss progress here.
}
@Override
protected void onPreExecute() {
super.onPreExecute();
//create and show progress dialog here
}
@Override
protected Void doInBackground(Void… arg0) {
//background task here
return null;
}
}
and execute like this:
myAsyncTask myWebFetch = new myAsyncTask();
myWebFetch.execute();
Hope it Helps!!