android - Leaking window when changing orientation -


i'm popping alertdialog users can type in new item add list. however, whenever screen orientation changes, logcat spits out bunch of errors regarding window leak. can't quite figure out i'm doing wrong here.

private void launchpopup() {     if (mtypedtext == null) {         mtypedtext = "";     }      layoutinflater inflater = (layoutinflater) activitytags.this.getsystemservice(layout_inflater_service);     view layout = inflater.inflate(r.layout.layout_additem, (viewgroup) findviewbyid(r.id.additem_root));      final textview text = (textview)layout.findviewbyid(r.id.additem_text);     text.settext("type in name of new item.");     text.setlines(1);      final edittext name = (edittext)layout.findviewbyid(r.id.additem_name);     name.addtextchangedlistener(new textwatcher() {         public void ontextchanged(charsequence s, int start, int before, int count) {}          public void beforetextchanged(charsequence s, int start, int count, int after) {}          public void aftertextchanged(editable s) {             if (s != null) {                 mtypedtext = s.tostring();             }             else {                 mtypedtext = null;             }         }     });     if (mtypedtext != null) {         name.settext(mtypedtext);     }      madddialog = new alertdialog.builder(activityitems.this);     madddialog.settitle("add item");     madddialog.setview(layout);     madddialog.setpositivebutton("ok", new dialoginterface.onclicklistener() {     public void onclick(dialoginterface dialoginterface, int i) {         // todo     } });     madddialog.setnegativebutton("cancel", new dialoginterface.onclicklistener() {     public void onclick(dialoginterface dialoginterface, int i) {         mtypedtext = null;     } });     madddialog.show(); } 

in onstop(), madddialog set null if not null.

here error:

activity com.myapp.app.activity.activityitems has leaked window com.android.internal.policy.impl.phonewindow$decorview@45164f30 added here android.view.windowleaked: activity com.myapp.app.activity.activityitems has leaked window com.android.internal.policy.impl.phonewindow$decorview@45164f30 added here @ android.view.viewroot.<init>(viewroot.java:247) @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:148) @ android.view.windowmanagerimpl.addview(windowmanagerimpl.java:91) @ android.view.window$localwindowmanager.addview(window.java:424) @ android.app.dialog.show(dialog.java:241) @ android.app.alertdialog$builder.show(alertdialog.java:802) ... 


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -