I have an error below:
//TODO tryAgain
private void tryAgain(){
new AlertDialog.Builder(this)
.setTitle(\"Game Over\")
.setMessage(\"Times Up!\")
This can occur when you are showing the dialog for a context that no longer exists. When you are calling show()
of dialog the activity is destroyed. This happens generally after async operations. Make sure that your activity(in which you want to show dialog) is running.
Don't call the activity after finishing it just create a new intent and start the activity. Do like this:
private void tryAgain(){
new AlertDialog.Builder(this)
.setTitle("Game Over")
.setMessage("Times Up!")
.setPositiveButton("Try Again?", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent retry = new Intent(this, Stage1_3.class);//I guess Stage1_3 is the current activity
finish();
startActivity(retry);
}
})
.setNegativeButton("Back to Menu", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent i = new Intent(Stage1_3.this, ShapingColors.class);
finish();
startActivity(i);
}
})
.show();
}