Control App Exit With Some Alert Dialog

Java Code:


// Back AlertDialog Start
@Override
public void onBackPressed() {

new AlertDialog.Builder(MainActivity.this)
.setTitle("Confirm Exit!!")
.setMessage("Are You Sure,You Want To Exit")
.setIcon(R.drawable.alert)

.setPositiveButton("Yes, Exit!", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
finishAndRemoveTask();
}
})

.setNegativeButton("No,Thanks", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})

.setNeutralButton("Rate Us", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent rateIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + MainActivity.this.getPackageName()));
startActivity(rateIntent);
drawer_layout.closeDrawer(GravityCompat.START);

}
})
.show();
}

// Back AlertDialog Start

Comments

Popular posts from this blog

Navigation And Bottom Font Style

Flutter Native Splash