As I'm creating an android application in which first I've created main activity, then I've added splash activity along with the one normal activity.
So my problem is whenever I click on exit in my app it closes the main activity and returns that one normal activity in splash activity.
I am using finish();
on exit button which is present in main activity.
So how can I exit the app which comes to android launcher screen
I've also tried creating new intent with Action Main but its only minimizing the app I want to close it
MainActivity.class
if (id == R.id.exit) {
AlertDialog.Builder builder = new AlertDialog.Builder(homeActivity.this);
builder.setMessage("Do You Want To Exit?").setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.setIcon(R.drawable.ic_error_outline_black_24dp);
alert.setTitle("Exit!!");
alert.show();
}
When starting the
MainAcitivity
fromSplashActivity
set flags in intent as below and callfinish()
onSplashAcitivty