I am working on an app in which I have one dialog and when I click on the exit button I want to close the app but sometimes app won't finish and return back to my first activity. I do not understand what to do with this.
Code for the same
AlertDialog.Builder alertDialog = new AlertDialog.Builder(getContext());
alertDialog.setMessage(context.getResources().getString(R.string.app_close_dialog_msg));
alertDialog.setPositiveButton(R.string.app_close_dialog_msg_yes, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dismiss();
((Activity) context).finish();
//((Activity) context). moveTaskToBack(true);
System.exit(0);
android.os.Process.killProcess(android.os.Process.myPid());
}
});