Logcat:
06-13 18:25:37.534: E/WindowManager(420): Activity com.dimensionsco.thankbunny.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@43ef3c98 that was originally added here
This is the code i was using to exit application with alert dialog. But it is ending up with errors. I dont understand where i went wrong.I am running it on emulator. Could any one solve this? Thanks in advance
@Override
public void onStop() {
super.onStop();
Toast.makeText(getBaseContext(), "stop", Toast.LENGTH_LONG).show();
AlertDialog.Builder alertDialogBuilde = new AlertDialog.Builder(MainActivity.this);
alertDialogBuilde.setTitle(this.getTitle() + "EXIT");
alertDialogBuilde.setMessage("DO you want to exit?");
AlertDialog alertDialogr = alertDialogBuilde.create();
alertDialogBuilde.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// go to a new activity of the app
dialog.cancel();
// finish();
}
});
alertDialogBuilde.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
// set neutral button: Exit the app message
alertDialogBuilde.setNeutralButton("Exit the app", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// exit the app and go to the HOME
System.exit(0);
// MainActivity.this.finish();
}
});
alertDialogr.show();
}