Android Presentation Window Leaked -
i trying display activity on display(monitor) in android. problem occures in scenario when:
mainactivity going activity presentation , forth, after couple of these, disconnect cable connecting android device display application crashes. error not occur if randomly disconnect cable without entering activity many times.
error
06-27 14:35:32.403: e/windowmanager(21837): android.view.windowleaked: activity com.example.doublescreen.newactivity has leaked window com.android.internal.policy.impl.phonewindow$decorview{433b4970 v.e..... r.....i. 0,0- 1280,720} added here 06-27 14:35:32.403: e/windowmanager(21837): @ com.example.doublescreen.newactivity.showpresentation(newactivity.java:48) 06-27 14:35:32.403: e/windowmanager(21837): @ com.example.doublescreen.newactivity.oncreate(newactivity.java:39)
presentation code:
public class pdfpresentation extends presentation { private context mctx; public pdfpresentation(context outercontext, display display) { super(outercontext, display); mctx = outercontext; } protected void oncreate(bundle savedinstancestate) { relativelayout layout = new relativelayout(mctx); imageview imgv = new imageview(mctx); imgv.setbackground(getresources().getdrawable(r.drawable.pic)); layout.addview(imgv); setcontentview(layout); };
}
activity presentation
public class newactivity extends activity { private pdfpresentation mpresentation; private displaymanager displaymanager; private final displaymanager.displaylistener mdisplaylistener = new displaymanager.displaylistener() { @override public void ondisplayadded(int displayid) { } @override public void ondisplaychanged(int displayid) { } @override public void ondisplayremoved(int displayid) { mpresentation.dismiss(); } }; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_new); displaymanager = (displaymanager) this.getsystemservice(context.display_service); displaymanager.registerdisplaylistener(mdisplaylistener,null); showpresentation(); } private void showpresentation() { display[] presentationdisplays = displaymanager.getdisplays(displaymanager.display_category_presentation); if (presentationdisplays.length > 0) { display display = presentationdisplays[0]; mpresentation = new pdfpresentation(this, display); mpresentation.show(); } } @override protected void onpause() { super.onpause(); displaymanager.unregisterdisplaylistener(mdisplaylistener); }
}
you need dismiss()
presentation
@ point, need dismiss()
dialog
. right now, calling show()
.
Comments
Post a Comment