// [END auth_build_googleapiclient_ending] // [START auth_connection_flow_in_activity_lifecycle_methods] protected override void OnStart() { base.OnStart(); // Connect to the Fitness API Log(TAG, "Connecting..."); mClient.Connect(); }
protected override void OnStart() { base.OnStart(); logVerbose("Activity onStart, starting connecting GoogleApiClient"); mGoogleApiClient.Connect(); }
protected override void OnStart() { base.OnStart(); googleApiClient.Connect(); RegisterDeepLinkReceiver(); }
bool resolveConnectionFailure(Activity activity, Android.Gms.Common.Apis.GoogleApiClient client, ConnectionResult result, int requestCode, string fallbackErrorMessage) { if (result.HasResolution) { try { result.StartResolutionForResult(activity, requestCode); return(true); } catch (IntentSender.SendIntentException e) { // The intent was canceled before it was sent. Return to the default // state and attempt to connect to get an updated ConnectionResult. client.Connect(); return(false); } } else { // not resolvable... so show an error message int errorCode = result.ErrorCode; var dialog = GooglePlayServicesUtil.GetErrorDialog(errorCode, activity, requestCode); if (dialog != null) { dialog.Show(); } else { // no built-in dialog: show the fallback error message //ShowAlert (activity, fallbackErrorMessage); (new AlertDialog.Builder(activity)).SetMessage(fallbackErrorMessage) .SetNeutralButton(Android.Resource.String.Ok, delegate { }).Create().Show(); } return(false); } }
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 Android.Gms.Common.Apis.GoogleApiClient.Builder(this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi(Android.Gms.Plus.PlusClass.API).AddScope(Android.Gms.Plus.PlusClass.ScopePlusLogin) .AddApi(Android.Gms.Games.GamesClass.API).AddScope(Android.Gms.Games.GamesClass.ScopeGames) .Build(); // Set up click listeners FindViewById <ImageButton> (Resource.Id.button_open_inbox).Click += delegate { // show inbox! if (mGoogleApiClient != null && mGoogleApiClient.IsConnected) { StartActivityForResult(Android.Gms.Games.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; Android.Gms.Games.GamesClass.SignOut(mGoogleApiClient); mGoogleApiClient.Disconnect(); showSignInBar(); }; mGiftIcon = BitmapFactory.DecodeResource(Resources, Resource.Drawable.ic_send_gift); }
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.fragment_login, container, false); mProgressDialog = initializeProgressDialog(); var signInButton = view.FindViewById <SignInButton> (Resource.Id.sign_in_button); signInButton.SetSize(SignInButton.SizeWide); signInButton.Click += delegate { showProgressDialog(); mSignInButtonClicked = true; mGoogleApiClient.Connect(); }; view.FindViewById(Resource.Id.button_login_bikestore).Click += delegate { Toast.MakeText(Activity, Resource.String.login_bikestore_message, ToastLength.Long).Show(); }; return(view); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); textLastLocation = FindViewById <TextView>(Resource.Id.textLastLocation); textLocationUpdates = FindViewById <TextView>(Resource.Id.textLocationUpdates); googleApiClient = new Android.Gms.Common.Apis.GoogleApiClient.Builder(this) .AddApi(Android.Gms.Location.LocationServices.API) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .Build(); googleApiClient.Connect(); }
public void OnConnectionSuspended(int cause) { Log("onConnectionSuspended() called. Trying to reconnect."); mGoogleApiClient.Connect(); }
protected override void OnStart() { base.OnStart(); client.Connect(); }
public override void OnStart() { base.OnStart(); mGoogleApiClient.Connect(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // If you want to understand the life cycle more, you can use below command to turn on // verbose logging for this Activity on your testing device: // adb shell setprop log.tag.SignInActivity VERBOSE mIsLogVerbose = Android.Util.Log.IsLoggable(TAG, Android.Util.LogPriority.Verbose); SetContentView(Resource.Layout.sign_in_activity); restoreState(savedInstanceState); logVerbose("Activity onCreate, creating new GoogleApiClient"); mGoogleApiClient = buildGoogleApiClient(false); mSignInStatus = FindViewById <TextView> (Resource.Id.sign_in_status); mSignInButton = FindViewById <SignInButton> (Resource.Id.sign_in_button); mSignInButton.Click += (sender, e) => { if (!mGoogleApiClient.IsConnecting) { int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable(this); if (available != ConnectionResult.Success) { ShowDialog(DIALOG_GET_GOOGLE_PLAY_SERVICES); return; } mSignInClicked = true; mSignInStatus.Text = GetString(Resource.String.signing_in_status); resolveSignInError(); } }; mServerAuthCodeDisabledLabel = FindViewById <TextView> (Resource.Id.server_auth_code_disabled); mServerAuthCodeResetButton = FindViewById <View> (Resource.Id.server_auth_code_reset_button); mServerAuthCodeResetButton.Click += (sender, e) => { mServerAuthCodeRequired.Set(true); }; if (!isUsingOfflineAccess()) { mServerAuthCodeDisabledLabel.Visibility = ViewStates.Visible; mServerAuthCodeResetButton.Visibility = ViewStates.Gone; } else { mServerAuthCodeDisabledLabel.Visibility = ViewStates.Gone; mServerAuthCodeResetButton.Visibility = ViewStates.Visible; } mSignOutButton = FindViewById <View> (Resource.Id.sign_out_button); mSignOutButton.Click += (sender, e) => { if (mGoogleApiClient.IsConnected) { mGoogleApiClient.ClearDefaultAccountAndReconnect(); } }; mRevokeAccessButton = FindViewById(Resource.Id.revoke_access_button); mRevokeAccessButton.Click += async delegate { mServerAuthCodeRequired.Set(true); if (mGoogleApiClient.IsConnected) { // TODO: asyncify var result = //await Android.Gms.Plus.PlusClass.AccountApi //.RevokeAccessAndDisconnectAsync (mGoogleApiClient); .RevokeAccessAndDisconnect(mGoogleApiClient); /* * if (result.IsSuccess) { * mSignInStatus.SetText (Resource.String.revoke_access_status); * } else { * mSignInStatus.SetText (Resource.String.revoke_access_error_status); * } * mGoogleApiClient.Reconnect (); */ updateButtons(false /* isSignedIn */); } }; mScopeSelector = FindViewById <ToggleButton> (Resource.Id.scope_selection_toggle); mScopeSelector.CheckedChange += (sender, e) => { mGoogleApiClient.Disconnect(); // Since we changed the configuration, the cached connection result is no longer // valid. mConnectionResult = null; mGoogleApiClient = buildGoogleApiClient(e.IsChecked); mGoogleApiClient.Connect(); }; if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { ActionBar.SetDisplayHomeAsUpEnabled(true); } }
protected async override void OnStart() { base.OnStart(); googleApiClient.Connect(); }
protected override void OnStart() { base.OnStart(); Log("onStart"); mGoogleApiClient.Connect(); }