Close Appication


Last Updated:

  1. Mikes29

    Mikes29 New Member This Topic's Starter

    Joined:
    Oct 8, 2010
    Messages:
    3
    Likes Received:
    0
    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

    Joined:
    Dec 6, 2009
    Messages:
    3,354
    Likes Received:
    281
    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

    Joined:
    Oct 29, 2009
    Messages:
    9,691
    Likes Received:
    8,364
    I'll move this over to the developer forum for you.
     

Share This Page

Loading...