i wrote alertdialog and i try to exit app in ok click,i wrote some code but when i click OK button app starting again automaticly this is a my source
public class AlertDialogManager {
public void showAlertDialog(Context context, String message) {
AlertDialog alertDialog = new AlertDialog.Builder(context).create();
alertDialog.setMessage(message);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
}
});
alertDialog.show();
}
i call this class like this but i can't close app in OK click
if (!con.isConnectingToInternet()) {
alert.showAlertDialog(getActivity(),
"You have not internet connection");
} else {
mainthread.execute();
}
P.s i checked internet connection.it's working perfect.do't worry :)
what am i doing wrong? if anyone knows solution please help me