Close Appication

Discussion in 'Application Development' started by Mikes29, Oct 15, 2010.

  1. Mikes29

    Mikes29 New Member
    25

    Oct 8, 2010
    3
    0
    25
    Hi,

    I'm starting programming for android with eclipse and i have a question, hope you can help.

    The app i'm working now have various classes.java and must of them when open depend from the last one, the one o called the new Activity.

    So in my first screen i have a method to close my app with the typical "AlertDialog" for confirm if the user really wont to exit.

    The problem is this, i can navigate through all screens of my app no problem but when i wont to exit my app goes to one screen of the app.

    My question is if there's a way to finish all Activities at the same time so the app closes all an goes back to the operative system of the equipment where the app is running?

    This is my exit app:

    public boolean onKeyDown(int keyCode, KeyEvent event) {
    //Handle the back button
    if(keyCode == KeyEvent.KEYCODE_BACK) {
    //Ask the user if they want to quit
    new AlertDialog.Builder(this)
    .setIcon(android.R.drawable.ic_dialog_alert)
    .setTitle(getStringResourceByName("quit"))
    .setMessage(getStringResourceByName("really_quit"))
    .setPositiveButton(getStringResourceByName("yes"), new DialogInterface.OnClickListener() {

    @Override
    public void onClick(DialogInterface dialog, int which) {
    //Stop the activity
    finish();
    }

    }).setNegativeButton(getStringResourceByName("no"), null).show();

    return true;
    }
    else {

    return super.onKeyDown(keyCode, event);
    }

    }

    Thank's
     

    Advertisement

  2. takeshi

    takeshi Well-Known Member
    163

    Dec 6, 2009
    3,354
    282
    163
    This is really a user forum. There might a few developers in here but you'll have better luck in a developer forum.
     
  3. OfTheDamned

    OfTheDamned The Friendly Undead
    VIP Member
    813

    Oct 29, 2009
    9,692
    8,365
    813
    Right Behind You
    I'll move this over to the developer forum for you.
     

Share This Page

Loading...