开发者

Do I have to clean up all dialogs 'show' by my activity

开发者 https://www.devze.com 2023-01-18 07:47 出处:网络
In my activity, I show a dialog under some condition like this: public void showADialog(String title, String msg) {

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消