I have a dialog that checks to see if the internet is on. If it isn't on, I display a pop-up giving you the option to turn data on or exit the app. If you choose to turn data on it will take you to the settings page to turn data on. Here is the problem: When you press back from the settings page the dialog is still present, it doesn't get dismissed. Here is the code:
public void calldialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(
"You need to enable an internet connection in order to use this Chirps:")
.setCancelable(true)
.setPositiveButton("Turn on Data",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent newintent = new Intent(
android.provider.Settings.ACTION_WIRELESS_SETTINGS);
newintent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(newintent);
dialog.dismiss();
}
})
.setNegativeButton("Exit",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Main.this.finish();
}
});
builder.show();
}
When I only had one option the dialog functioned properly. But as soon as I add the second option it causes the button to show twice. The internet check function in which the the calldialog() is contained is called in both the oncreate and onresume which may be part of the problem.