I have an Activity called MyProgressDialog which contains a ProgressDialog. This ScreenProgressDialog activity is called in the Main activity by intents:
if(msg.what == SET_PROGRESS){
intent.putExtra("action", "set");
...
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else if(msg.what == SHOW_PROGRESS){
intent.putExtra("action", "show");
...
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
else if(msg.what == HIDE_PROGRESS){
intent.putExtra("action", "hide");
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
}
Here is the MyProgressDialog activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("screenPD", "spd created");
extras = getIntent().getExtras();
pd = new ProgressDialog(this);
...setting the pd...
pd.show();
Log.e("screenPD", "spd shown");
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
int newTitle = intent.getExtras().getInt("title");
if (intent.getExtras().getString("action").equals("set")){
pd.set methods...
pd.show();
Log.e("DialogSET", "DialogSET "+intent.getExtras().getInt("progress"));
}
else if (intent.getExtras().getString("action").equals("show")){
pd.set methods...
pd.show();
Log.e("DialogSHOW", "DialogSHOW "+progress);
}
else if (intent.getExtras().getString("action").equals("hide")){
pd.dismiss();
this.finish();
Log.e("DialogHIDE", "DialogHIDE");
return;
}
}
@Override
public void onDestroy() {
super.onDestroy();
Log.e("screenPD", "destroyed");
}
And here is the LogCat:
DialogHIDE(2615): DialogHIDE
screenPD(2615): spd created
screenPD(2615): spd shown
screenPD(2615): destroyed
So the 3rd intent starts, calls the finish(); return; and the Onreate method is started which displays a new ProgressDialog. The onDestroy is called, but the ProgressDialog doesn't hide from the screen. After the finish() method the activity shold be closed. Where is the problem? Thank you!
There is no error. the method invoking finish()
will run out to completion and after its completion the controll returns to Android