Edit: Problem solved. Make it global. I’m doing a facepalm right now guys. Thanks!
Below are some snippets from a class that extends AsyncTask. I want to start a progressDialog in the preExecute() method and do a progressDialog.dismiss(); in the postExecute() method. All the examples I find say to do it like below. The problem I’m having is that dialog is out of scope in onPostExecute. This is expected except but all the examples seem to do it this way. I also noticed that up at the import there’s a little warning sign saying that the import is unused. Should this ProgressDialog work? Do I need to pass it around?
import android.app.ProgressDialog;
...
protected void onPostExecute(Bitmap image){//error when doing this in resetDisplay.... onPostExecute is invoked by the ui thread so this may be why it works here and not in resetDisplay
ImageView imageView=(ImageView) parent.findViewById(R.id.imageDisplay);
imageView.setImageBitmap(image);
dialog.dismiss();
}
protected void onPreExecute(){
ProgressDialog dialog=ProgressDialog.show(parent, "Loading", "Loading the image of the day");
}
1 Answer