0

I use code below to start an activity:

Intent intent = new Intent(XXX.this, YYY.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(data);

somehow, I don't know why, XXX's onResume() method is invoked. and because I try to pop up a progressDialog inside onResume(), I got below error:

`android.view.WindowLeaked: Activity XXX has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@406ca468 that was originally added here.`

In debug mode, I set a breakpoint at the first line of method onResume(), it never stops there, but still I get the above error.

why does this happen?

Pankaj
  • 7,908
  • 6
  • 42
  • 65
newme
  • 331
  • 1
  • 5
  • 11

1 Answers1

0

Because onResume is part of the Activity lifecycle, it will be called regardless of whether this is the first time your Activity is being created. If you want to open a dialog when the user returns to it, you should probably put that behaviour in onRestart, not onResume.

Edit: Without seeing your dialog creation code, it's hard to say what causes the error. However, make sure you are placing a call to showDialog and returning a created Dialog from onCreateDialog, not just creating the Dialog itself in onResume.

Xono
  • 1,900
  • 17
  • 20
  • it is mProgressDialog = ProgressDialog.show(this, "", getResources().getString(R.string.notice_login_server), true, false); – newme Jun 17 '12 at 07:24
  • if Intent.FLAG_ACTIVITY_REORDER_TO_FRONT is used, onresume is called instead of onrestart – newme Jun 17 '12 at 07:25