I am trying to dismiss a progress dialog but it doesnt seem to work for some reason. Any suggestions why is it so??
The progress dialog is initialized on button click and shows the dialog. The syncbutton method calls a thread which sends an empty message
thanks
mHandler.sendEmptyMessage(0);//from thread
Code for button click
public void onClick(View v) {
pd = new ProgressDialog(Screen.this);
pd.setCancelable(true);
ProgressDialog.show(Screen.this, "Sync", "Sync in progress",true,false);
SyncButton();
}
});
Code for message handler which should dismiss the progressbar
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
Log.d("Handler","handler");
if (Screen==true){
if (pd !=null)
{
pd.cancel();
pd.dismiss();
Log.d("HANDLER", "called dismiss");
}
}
}
};
PS: I did try using asynctask but was having problems with it. Thats why took this approach. I had posted that question here
Looke like you are creating one progress dialog here:
That one isn’t displayed. You create and display another one:
Remove the two first lines, and change your other line to: