• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Close app if dialog showing does not work

FSchmidt

Lurker
Hello,
this is my onBackPressed-Method:

Java:
@Override
public void onBackPressed() {
    if(drawer != null && drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START)
    } else if(confirmCloseAppDialog != null && confirmCloseAppDialog.isShowing()) {         
        closeApp();
    } else {
        confirmCloseAppDialog.show();
    }
}

My problem is, that the app does not close if the confirmCloseAppDialog is showing. Where is the problem?

Kind regards!
 
My problem is, that the app does not close if the confirmCloseAppDialog is showing. Where is the problem?

Your closeApp() method needs to have some code that actually closes the app. Can't say much else without knowing what code you have in that method for closing the app.
 
Last edited:
Hello,

closeApp() calles this.finish(). The same method is called if I press the "positive button" in my alertDialog - and it works.

My alertDialog is a static dialog, which is created in the onCreate-method of my main activity. After the declaration no changes will occur to this dialog.

Everything works except the app close, if the dialog is showing. What am I missing?


Edit: Why are you creating an intent in your clos-method?
 
Back
Top Bottom