I am starting progress dialog in my async task pre-execute, meanwhile if i get broadcast and if i perform some time consuming action within Broadcast Receiver , progress dialog is not getting dismissed.Async task is independent of broadcast receiver.Thank you in advance.Any help is appreciated.
class disconnecting extends AsyncTask<String, Void, Void> {
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog.setMessage(context.getResources().getText(
R.string.disconnecting));
progressDialog.show();
}
@Override
protected Void doInBackground(String... params) {
CommunicationManager.getInstance().Disconnecting(
params[0]);
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
progressDialog.dismiss();
}
}
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String lostId = intent.getStringExtra("ID");
System.out.println("LOST ID" + lostId);
}
};
I think this problem is related to multitasking.When control is in broadcast receiver(more time spent in receiver), async task progress dialog is not dismissed
Finally I got the solution.I had declared progress dialog has global so there was a problem in dismissing.Now I declared the dialog within async task, it worked..progress dialog is getting dismissed.