tags:

views:

37

answers:

1

Hi,

In my activity, I show a dialog under some condition like this:

public void showADialog(String title, String msg) {
    if (mIsActivityRunning) {
        new AlertDialog.Builder(this)
        .show();
    }
} 

My question is what do I need to do to ensure there is no resource leak? From the logcat, i see there is a case where it said a window is leaking or something like that.

A: 

When the dialog box closes, how are you dismissing it? If you are using the hide() method, this won't actually dismiss the dialog.

EDIT: You need to dispose of the dialog box as the Activity is disposed of - see this question for more details

SamStephens
what if I just call dialog.show(), and then I just do a screen rotation? or I launch another activity. Does that mean I need to close/destory my dialog manually? or android does it for me?
michael
Have edited my answer.
SamStephens