Overriding the OnBackPressed activity

With our iOS implementation we integrated an override to the navigation back button, so when a user leaves the ClientListViewController, we ask the user if they would like to signout from the ChatHub. We are going to do the same here but on the Android platform. We will be building the alert from the AlertDialog.Builder framework:

public override void OnBackPressed()
         {
             //Put up the Yes/No message box
             AlertDialog.Builder builder = new AlertDialog.Builder(this);
             builder
                 .SetTitle("Chat")
                 .SetMessage("Would you like to signout?")
                 .SetNegativeButton("No", (sender, e) => { })
                 .SetPositiveButton("Yes", (sender, e) =>
                      {
                          _presenter.Signout();
                     })
                 .Show();
         }

We start with instantiating a new builder object which must ...

Get Xamarin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.