public AndroidDatabaseProvider(Activity activity) { this.activity = activity; GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.Instance; if (googleApiAvailability.IsGooglePlayServicesAvailable(activity) == ConnectionResult.Success) { string accountName; using (ISharedPreferences settings = activity.GetSharedPreferences(SETTINGS_NAME, FileCreationMode.Private)) { accountName = settings.GetString(SETTINGS_STRING_ACCOUNTNAME, string.Empty); } global::Android.Widget.Toast.MakeText(activity, "awdawd", Android.Widget.ToastLength.Short); GoogleApiClient.Builder builder = new GoogleApiClient.Builder(activity, this, this) .AddApi(GamesClass.API) .AddScope(GamesClass.ScopeGames) .AddApi(DriveClass.API) .AddScope(DriveClass.ScopeAppfolder); if (!string.IsNullOrEmpty(accountName)) { builder.SetAccountName(accountName); } _GoogleApiClient = builder.Build( ); _GoogleApiClient.Connect( ); } localStateDatabase = activity.GetSharedPreferences(LOCAL_COPY_STATE_NAME, FileCreationMode.Private); }
private void CreateClient() { // did we log in with a player id already? If so we don't want to ask which account to use var settings = this.activity.GetSharedPreferences("googleplayservicessettings", FileCreationMode.Private); var id = settings.GetString("playerid", String.Empty); var builder = new GoogleApiClient.Builder(activity, this, this); builder.AddApi(Android.Gms.Games.GamesClass.API); builder.AddScope(Android.Gms.Games.GamesClass.ScopeGames); builder.SetGravityForPopups((int)GravityForPopups); if (ViewForPopups != null) { builder.SetViewForPopups(ViewForPopups); } if (!string.IsNullOrEmpty(id)) { builder.SetAccountName(id); } client = builder.Build(); }
private void CreateClient() { // did we log in with a player id already? If so we don't want to ask which account to use var settings = this.activity.GetSharedPreferences ("googleplayservicessettings", FileCreationMode.Private); var id = settings.GetString ("playerid", String.Empty); var builder = new GoogleApiClient.Builder (activity, this, this); builder.AddApi (Android.Gms.Games.GamesClass.API); builder.AddScope (Android.Gms.Games.GamesClass.ScopeGames); builder.SetGravityForPopups ((int)GravityForPopups); if (ViewForPopups != null) builder.SetViewForPopups (ViewForPopups); if (!string.IsNullOrEmpty (id)) { builder.SetAccountName (id); } client = builder.Build (); }