public void SignOut() { SignedOut = true; if (client.IsConnected) { GamesClass.SignOut(client); Stop(); using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutString("playerid", String.Empty); e.Commit(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("nickname", "Not logged player"); editor.Commit(); } } client.Dispose(); client = null; if (OnSignedOut != null) { OnSignedOut(this, EventArgs.Empty); } } }
/// <summary> /// Sign out of Google Play and make sure we don't try to auto sign in on the next startup /// </summary> public void SignOut() { this.SignedOut = true; if (this.client.IsConnected) { GamesClass.SignOut(this.client); this.Stop(); using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutString("playerid", String.Empty); e.Commit(); } } this.client.Dispose(); this.client = null; if (this.OnSignedOut != null) { this.OnSignedOut(this, EventArgs.Empty); } } }
public void OnConnected(Android.OS.Bundle connectionHint) { resolving = false; SignedOut = false; signingin = false; using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { AccountManager manager = AccountManager.Get(Application.Context); Account[] accounts = manager.GetAccountsByType("com.google"); e.PutString("playerid", GamesClass.GetCurrentAccountName(client)); e.Commit(); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context); ISharedPreferencesEditor editor = prefs.Edit(); editor.PutString("nickname", GamesClass.Players.GetCurrentPlayer(client).DisplayName); editor.Commit(); } } if (OnSignedIn != null) { OnSignedIn(this, EventArgs.Empty); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); Log("onCreate()"); // Create the Google Api Client with access to Plus and Games mGoogleApiClient = new GoogleApiClient.Builder(this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(PlusClass.API).AddScope(PlusClass.ScopePlusLogin) .AddApi(GamesClass.API).AddScope(GamesClass.ScopeGames) .Build(); // Set up click listeners FindViewById <ImageButton> (Resource.Id.button_open_inbox).Click += delegate { // show inbox! if (mGoogleApiClient != null && mGoogleApiClient.IsConnected) { StartActivityForResult(GamesClass.Requests.GetInboxIntent(mGoogleApiClient), SHOW_INBOX); } }; FindViewById <ImageButton> (Resource.Id.button_send_gift).Click += delegate { // send gift! showSendIntent(GameRequest.TypeGift); }; FindViewById <ImageButton> (Resource.Id.button_send_request).Click += delegate { // request gift! showSendIntent(GameRequest.TypeWish); }; FindViewById <SignInButton> (Resource.Id.button_sign_in).Click += delegate { // Check to see the developer who's running this sample code read the instructions :-) // NOTE: this check is here only because this is a sample! Don't include this // check in your actual production app. //if (!BaseGameUtils.VerifySampleSetup (this, Resource.String.app_id)) // Log ("*** Warning: setup problems detected. Sign in may not work!"); // start the sign-in flow Log("Sign-in button clicked"); mSignInClicked = true; mGoogleApiClient.Connect(); }; FindViewById <Button> (Resource.Id.button_sign_out).Click += delegate { // sign out. Log("Sign-out button clicked"); mSignInClicked = false; GamesClass.SignOut(mGoogleApiClient); mGoogleApiClient.Disconnect(); showSignInBar(); }; mGiftIcon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_send_gift); }
public void OnConnected(Bundle connectionHint) { using (ISharedPreferences settings = activity.GetSharedPreferences(SETTINGS_NAME, FileCreationMode.Private)) { using (ISharedPreferencesEditor editor = settings.Edit( )) { editor.PutString(SETTINGS_STRING_ACCOUNTNAME, GamesClass.GetCurrentAccountName(_GoogleApiClient)); editor.Commit( ); } } OnConnectedToGoogle?.Invoke( ); }
public void OnConnected(Android.OS.Bundle connectionHint) { GamerPlatformSettings.Instance.ShouldBeSignedIn = true; GamerPlatformSettings.Instance.PlayerId = GamesClass.GetCurrentAccountName(_client); GamerPlatformSettings.Instance.Serialize(); _resolving = false; _signingIn = false; OnSignedIn(); }
/// <summary> /// Sign out of Google Play and make sure we don't try to auto sign in on the next startup /// </summary> public void SignOut() { SignedOut = true; if (client.IsConnected) { GamesClass.SignOut(client); Stop(); client.Dispose(); client = null; OnSignedOut?.Invoke(this, EventArgs.Empty); } }
public void Logout() { GamerPlatformSettings.Instance.ShouldBeSignedIn = false; GamerPlatformSettings.Instance.PlayerId = string.Empty; GamerPlatformSettings.Instance.Serialize(); if (_client.IsConnected) { GamesClass.SignOut(_client); Stop(); _client.Dispose(); _client = null; OnSignedOut(); } }
public void OnConnected(Android.OS.Bundle connectionHint) { resolving = false; SignedOut = false; signingin = false; using (var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private)) { using (var e = settings.Edit()) { e.PutString("playerid", GamesClass.GetCurrentAccountName(client)); e.Commit(); } } if (OnSignedIn != null) { OnSignedIn(this, EventArgs.Empty); } }
public void OnClick(View v) { Intent intent; switch (v.Id) { case Resource.Id.button_single_player: case Resource.Id.button_single_player_2: // play a single-player game ResetGameVars(); StartGame(false); break; case Resource.Id.button_sign_in: // start the sign-in flow Log.Debug(TAG, "Sign-in button clicked"); mSignInClicked = true; mGoogleApiClient.Connect(); break; case Resource.Id.button_sign_out: // user wants to sign out // sign out. Log.Debug(TAG, "Sign-out button clicked"); mSignInClicked = false; GamesClass.SignOut(mGoogleApiClient); mGoogleApiClient.Disconnect(); SwitchToScreen(Resource.Id.screen_sign_in); break; case Resource.Id.button_invite_players: // show list of invitable players intent = GamesClass.RealTimeMultiplayer.GetSelectOpponentsIntent(mGoogleApiClient, 1, 3); SwitchToScreen(Resource.Id.screen_wait); StartActivityForResult(intent, RC_SELECT_PLAYERS); break; case Resource.Id.button_see_invitations: // show list of pending invitations intent = GamesClass.Invitations.GetInvitationInboxIntent(mGoogleApiClient); SwitchToScreen(Resource.Id.screen_wait); StartActivityForResult(intent, RC_INVITATION_INBOX); break; case Resource.Id.button_accept_popup_invitation: // user wants to accept the invitation shown on the invitation popup // (the one we got through the OnInvitationReceivedListener). AcceptInviteToRoom(mIncomingInvitationId); mIncomingInvitationId = null; break; case Resource.Id.button_quick_game: // user wants to play against a random opponent right now StartQuickGame(); break; case Resource.Id.button_click_me: ScoreOnePoint(); break; } }
public static void SetViewForPopups(View view) => GamesClass.SetViewForPopups(googleClient, view);