In my game, the GameOver page allows users to submit their scores to the server.
I want to show an alert dialog if the submission is successful or not. Since the GameOver page belongs in a PCL in a separate project and does not inherit the GameActivity, what is the proper way to get the application Context and show the alert dialog from the GameOver
page?
UPDATE:
What I’ve done so far is to pass the GameActivity Context as parameter to any class that needs it
private Context context;
....
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
Game game = new SpaceShooterX.Game1 ();
SetContentView ((View)game.Services.GetService (typeof(View)));
game.Run();
context = this;
MessageBoxHelper messageBoxHelper = new MessageBoxHelper (context);
SpaceX.MessageBoxHelper.IMsgBoxHelper = messageBoxHelper;
}
The alertdialog was not shown. No error message. I placed a break point to confirm alert.Show() was called.
public void ShowOK()
{
AlertDialog.Builder alert = new AlertDialog.Builder (context);
alert.SetTitle ("Hi, how are you");
alert.SetPositiveButton ("Good", (senderAlert, args) => {
} );
alert.SetNegativeButton ("Not doing great", (senderAlert, args) => {
} );
alert.Show();
}
What am I doing wrong?