Check status of dialog in android -


i create dialog by:

protected void showalertdialog(string title, string message) {     alertdialog.builder builder = new builder(this);     if(title != null) {         builder.settitle(title);     }     if(message != null) {         builder.setmessage(message);     }     builder.setpositivebutton("ok", new onclicklistener() {          @override         public void onclick(dialoginterface dialog, int which) {             backtomainactivity();         }     });     builder.show(); } 

and after use in activity. how can check status dialog. mean want check when dialog canceled or closed. way that? have example when user click backbutton , dialog closed , want finish activity when dialog closed. way check if dialog showing or closed?

you may add cancel button dialog:

builder.setnegativebutton("cancel", new onclicklistener() {  @override         public void onclick(dialoginterface dialog, int which) {             //your code here         }     }); 

if want dialog ok button may else using such methods - setoncancellistener, setondissmislistener on builder.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -