Wednesday, February 4, 2015

android application exit with Activity.finish() when back pressed

@Override
    public void onBackPressed() {
        new AlertDialog.Builder(this)
                .setMessage(R.string.system_exit_confirm_message)
                .setCancelable(false)
                .setPositiveButton(R.string.btn_yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        finish();
                    }
                })
                .setNegativeButton(R.string.btn_no, null)
                .show();
    }

No comments: