private async void ResolveSignInError() { if (mGoogleApiClient.IsConnected) { Toast.MakeText(this, "Already Authenticated!!!!!!!!!!!!", ToastLength.Long).Show(); //StartActivity(typeof(farmer_home)); StartActivity(typeof(MainActivity)); //No need to resolve errors, already connected return; } if (mConnectionResult.HasResolution) { try { mIntentInProgress = true; StartIntentSenderForResult(mConnectionResult.Resolution.IntentSender, 0, null, 0, 0, 0); } catch (Android.Content.IntentSender.SendIntentException e) { //The intent was cancelled before it was sent. Return to the default //state and attempt to connect to get an updated ConnectionResult mIntentInProgress = false; mGoogleApiClient.Connect(); } } }
protected override void OnStart() { base.OnStart(); logVerbose("Activity onStart, starting connecting GoogleApiClient"); mGoogleApiClient.Connect(); }
protected override void OnStart() { base.OnStart(); // Connect to the Fitness API Log.Info(TAG, "Connecting..."); mClient.Connect(); }
public void AddGeofences() { // Start a request to add geofences mRequestType = RequestType.Add; // Test for Google Play services after setting the request type if (!IsGooglePlayServicesAvailable) { Log.Error(Constants.TAG, "Unable to add geofences - Google Play services unavailable."); return; } // Create a new location client object. Since this activity implements ConnectionCallbacks and OnConnectionFailedListener, // it can be used as the listener for both parameters apiClient = new GoogleApiClientBuilder(this, this, this) .AddApi(LocationServices.API) .Build(); // If a request is not already underway if (!mInProgress) { // Indicate that a request is underway mInProgress = true; // Request a connection from the client to Location Services apiClient.Connect(); } else { // A request is already underway, so disconnect the client and retry the request apiClient.Disconnect(); apiClient.Connect(); } }
protected override void OnStart() { if (client != null) { client.Connect(); } base.OnStart(); }
/// <summary> /// Called when the App first starts, after OnCreate is called. /// </summary> protected override void OnStart() { base.OnStart(); mGoogleApiClient.Connect(); Toast.MakeText(this, "Connecting", ToastLength.Long).Show(); }
protected override void OnStart() { base.OnStart(); if (!mResolvingError) { mGoogleApiClient.Connect(); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); RequestWindowFeature(WindowFeatures.ActionBar); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); ActionBar.SetIcon(Resource.Drawable.appiconaction); settingsFragment = new SettingsFragment(); settingsFragment.OnSettingsChanged += Synchronize; FragmentManager.BeginTransaction() .Replace(Resource.Id.fragment_container, settingsFragment) .Commit(); googleClient = new GoogleApiClientBuilder(this) .AddApi(WearableClass.Api) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .Build(); googleClient.Connect(); }
protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); RequestWindowFeature (WindowFeatures.ActionBar); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); ActionBar.SetIcon (Resource.Drawable.appiconaction); settingsFragment = new SettingsFragment (); settingsFragment.OnSettingsChanged += Synchronize; FragmentManager.BeginTransaction () .Replace (Resource.Id.fragment_container, settingsFragment) .Commit (); googleClient = new GoogleApiClientBuilder (this) .AddApi (WearableClass.Api) .AddConnectionCallbacks (this) .AddOnConnectionFailedListener (this) .Build (); googleClient.Connect (); }
public override void OnVisibilityChanged(bool visible) { base.OnVisibilityChanged(visible); if (Log.IsLoggable(Tag, LogPriority.Debug)) { Log.Debug(Tag, "OnVisibilityChanged: " + visible); } if (visible) { googleApiClient.Connect(); RegisterTimezoneReceiver(); } else { UnregisterTimezoneReceiver(); if (googleApiClient != null && googleApiClient.IsConnected) { WearableClass.DataApi.RemoveListener(googleApiClient, this); googleApiClient.Disconnect(); } } UpdateTimer(); }
void LaunchReceiver() { try { var _castListener = new MyCastListener { ApplicationDisconnected = delegate(int statusCode) { Console.WriteLine("Application disconnected - code {0}", statusCode); Teardown(true); } }; var apiOptionsBuilder = new CastClass.CastOptions.Builder(_selectedDevice, _castListener) .Build(); _apiClient = new GoogleApiClientBuilder(this, this, this) .AddApi(CastClass.API, apiOptionsBuilder) .Build(); _apiClient.Connect(); } catch (Exception e) { Console.WriteLine("Failed LaunchReceiver - {0}", e); } }
void SetupGeofencing() { client = new GoogleApiClientBuilder (this, this, this) .AddApi (LocationServices.API) .Build (); client.Connect (); }
public override void OnCreate () { base.OnCreate (); mGoogleApiClient = new GoogleApiClientBuilder (this.ApplicationContext) .AddApi (WearableClass.Api) .Build (); mGoogleApiClient.Connect (); }
protected override void OnResume() { base.OnResume(); Log.Debug("OnResume", "OnResume called, reconnecting..."); locClient.Connect(); }
protected override void OnStart() { base.OnStart(); if (!google_api_client.IsConnected) { google_api_client.Connect(); } }
public override void OnCreate() { base.OnCreate(); googleApiClient = new GoogleApiClientBuilder(this.ApplicationContext) .AddApi(WearableClass.Api) .Build(); googleApiClient.Connect(); }
protected override void OnResume() { base.OnResume(); if (!mGoogleApiClient.IsConnected) { mGoogleApiClient.Connect(); } }
public void StartGetLocation() { if (apiClient != null) { Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(ViewModel, true)); apiClient.Connect(); } }
protected override void OnResume() { base.OnResume(); Log.Debug("OnResume", "OnResume called, connecting to client..."); apiClient.Connect(); // Clicking the first button will make a one-time call to get the user's last location button.Click += delegate { if (apiClient.IsConnected) { button.Text = "Getting Last Location"; Location location = LocationServices.FusedLocationApi.GetLastLocation(apiClient); if (location != null) { latitude.Text = "Latitude: " + location.Latitude.ToString(); longitude.Text = "Longitude: " + location.Longitude.ToString(); provider.Text = "Provider: " + location.Provider.ToString(); Log.Debug("LocationClient", "Last location printed"); } } else { Log.Info("LocationClient", "Please wait for client to connect"); } }; // Clicking the second button will send a request for continuous updates button2.Click += delegate { if (apiClient.IsConnected) { button2.Text = "Requesting Location Updates"; // Setting location priority to PRIORITY_HIGH_ACCURACY (100) locRequest.SetPriority(100); // Setting interval between updates, in milliseconds // NOTE: the default FastestInterval is 1 minute. If you want to receive location updates more than // once a minute, you _must_ also change the FastestInterval to be less than or equal to your Interval locRequest.SetFastestInterval(500); locRequest.SetInterval(1000); Log.Debug("LocationRequest", "Request priority set to status code {0}, interval set to {1} ms", locRequest.Priority.ToString(), locRequest.Interval.ToString()); // pass in a location request and LocationListener LocationServices.FusedLocationApi.RequestLocationUpdates(apiClient, locRequest, this); // In OnLocationChanged (below), we will make calls to update the UI // with the new location data } else { Log.Info("LocationClient", "Please wait for Client to connect"); } }; }
void RequestMonitoringStart() { //If connected to google play services then add regions if (mGoogleApiClient.IsConnected) { AddGeofences(); } else { //If not connection then connect if (!mGoogleApiClient.IsConnecting) { mGoogleApiClient.Connect(); } //Request to add geofence regions once connected CurrentRequestType = RequestType.Add; } }
public override void OnCreate () { base.OnCreate (); if (Log.IsLoggable (Constants.TAG, LogPriority.Info)) Log.Info (Constants.TAG, "HomeListenerService created"); mGoogleApiClient = new GoogleApiClientBuilder (this.ApplicationContext) .AddApi (WearableClass.Api) .Build (); mGoogleApiClient.Connect (); }
public void OnDisconnected() { Log.Debug("LocClient", "Disconnected"); client = null; // If the client was disconnected too early if (currentRequest != ConnectionUpdateRequest.None) { client = CreateGoogleClient(); client.Connect(); } }
private void ResolveSignInAlerta() { if (mGoogleApiClient.IsConnected) { return; } if (mConnectionResult.HasResolution) { try { mIntentInProgress = true; StartIntentSenderForResult(mConnectionResult.Resolution.IntentSender, 0, null, 0, 0, 0); } catch (Android.Content.IntentSender.SendIntentException e) { mIntentInProgress = false; mGoogleApiClient.Connect(); } } }
public override void OnCreate() { base.OnCreate(); _client = new GoogleApiClientBuilder(this.ApplicationContext) .AddApi(WearableClass.Api) .Build(); _client.Connect(); Android.Util.Log.Info("WearIntegration", "Created"); }
public override void OnCreate() { base.OnCreate(); _client = new GoogleApiClientBuilder(this.ApplicationContext) .AddApi(WearableClass.Api) .Build(); _client.Connect(); Android.Util.Log.Info("WearIntegration", "Created"); }
public void Start() { if (!GamerPlatformSettings.Instance.ShouldBeSignedIn && !_signingIn) { return; } if (_client != null && !_client.IsConnected) { _client.Connect(); } }
public void StartUpdatingLocation () { if (_googleApiClient == null) { _googleApiClient = new GoogleApiClientBuilder (Forms.Context) .AddApi (LocationServices.API) .AddConnectionCallbacks (this) .AddOnConnectionFailedListener (this) .Build (); _googleApiClient.Connect (); } }
public override void OnCreate() { base.OnCreate(); if (Log.IsLoggable(Constants.TAG, LogPriority.Info)) { Log.Info(Constants.TAG, "HomeListenerService created"); } mGoogleApiClient = new GoogleApiClientBuilder(this.ApplicationContext) .AddApi(WearableClass.Api) .Build(); mGoogleApiClient.Connect(); }
protected override void OnResume() { base.OnResume(); if (!_client.IsConnected) { _client.Connect(); } //register sensor listener if (sensorManager.RegisterListener(sl, heartRateSensor, SensorDelay.Normal)) { System.Diagnostics.Debug.WriteLine("SensorListener registered"); } }
protected override void OnResume() { base.OnResume(); apiClient.Connect(); if (ViewModel.IsEditMode) { if (Mvx.Resolve <ICacheService>().NextStatus == AddSpotStatus.Activation) { return; } if (Mvx.Resolve <ICacheService>().NextStatus != AddSpotStatus.GotoSpot && Mvx.Resolve <ICacheService>().NextStatus != AddSpotStatus.Complete) { ViewModel.DoAddOrSaveParkingSpot(); } else if (Mvx.Resolve <ICacheService>().NextStatus == AddSpotStatus.Complete) { ViewModel.DoAddOrSaveParkingSpot(); } } else { if (Mvx.Resolve <ICacheService>().NextStatus == AddSpotStatus.SpotCalendar) { ViewModel.DoAddOrSaveParkingSpot(); } else if (Mvx.Resolve <ICacheService>().NextStatus == AddSpotStatus.Complete) { ViewModel.SaveParkingSpot(); } } if (Mvx.Resolve <ICacheService>().NextStatus != ViewModel.Status) { ViewModel.UpdateTasksStatus(Mvx.Resolve <ICacheService>().NextStatus); } if (ViewModel.Status == AddSpotStatus.GPS) { GetGPS(); } if (ViewModel.Parking != null && Mvx.Resolve <ICacheService>().CreateParkingRequest != null && Mvx.Resolve <ICacheService>().CreateParkingRequest.HourlyRate != null) { ViewModel.Parking.HourlyRate = Mvx.Resolve <ICacheService>().CreateParkingRequest.HourlyRate; } }
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data) { if (requestCode == ConnectionFailureResolutionRequest) { if (resultCode == Result.Ok && CheckGooglePlayServices ()) { if (client == null) { client = CreateApiClient (); client.Connect (); } SwitchTo (mapFragment = new HubwayMapFragment (this)); } else Finish (); } else { base.OnActivityResult (requestCode, resultCode, data); } }
public void connectGoogleAPI() { System.Diagnostics.Debug.Assert(_googleAPI != null); if (!_googleAPI.IsConnectionCallbacksRegistered(this)) { _googleAPI.RegisterConnectionCallbacks(this); } if (!_googleAPI.IsConnectionFailedListenerRegistered(this)) { _googleAPI.RegisterConnectionFailedListener(this); } if (!_googleAPI.IsConnected || !_googleAPI.IsConnecting) { _googleAPI.Connect(); } }
protected override void OnResume() { base.OnResume(); ViewModel.Title = "Acquiring location…"; StartTimer(); if (Mvx.Resolve <ICacheService>().SearchMode == SearchMode.Now) //park me now { Start60sTimer(); apiClient.Connect(); Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this.ViewModel, true)); } else //park me later { ViewModel.GetParkingLists(); } ViewModel.UpdateValidTime(); }
void Init () { mediaRouter = MediaRouter.GetInstance (this); mediaRouteSelector = new MediaRouteSelector.Builder ().AddControlCategory (MediaControlIntent.CategoryRemotePlayback) //CastMediaControlIntent.CategoryForCast (APP_ID)) .Build(); mediaRouteButton.RouteSelector = mediaRouteSelector; myMediaRouterCallback = new MyMediaRouterCallback { OnRouteSelectedHandler = (router, route) => { Console.WriteLine ("Route Selected: " + route.Name); var device = CastDevice.GetFromBundle(route.Extras); myCastListener = new MyCastListener(); var apiOptionsBuilder = new CastClass.CastOptions.Builder ( device, myCastListener).SetVerboseLoggingEnabled (true); googleApiClient = new GoogleApiClientBuilder(this) .AddApi (CastClass.API, apiOptionsBuilder.Build()) .AddConnectionCallbacks (this) .AddOnConnectionFailedListener (this) .Build (); googleApiClient.Connect(); }, OnRouteUnselectedHandler = (router, route) => { Console.WriteLine ("Route Unselected: " + route.Name); }, RouteCountChangedHandler = newCount => { mediaRouteButton.Visibility = newCount > 0 ? ViewStates.Visible : ViewStates.Gone; } }; mediaRouter.AddCallback(mediaRouteSelector, myMediaRouterCallback, MediaRouter.CallbackFlagRequestDiscovery); }
public void SetTrackingEnabled(bool enabled, TrackingDelay desiredDelay = TrackingDelay.Long) { this.desiredDelay = desiredDelay; if (!enabled) { StopCurrentLocationTracking(); } if (currentRequest != ConnectionUpdateRequest.None) { return; } currentRequest = enabled ? ConnectionUpdateRequest.Start : ConnectionUpdateRequest.Stop; if (client == null) { client = CreateGoogleClient(); } if (!(client.IsConnected || client.IsConnecting)) { client.Connect(); } }
void Init() { mediaRouter = MediaRouter.GetInstance(this); mediaRouteSelector = new MediaRouteSelector.Builder().AddControlCategory(MediaControlIntent.CategoryRemotePlayback) //CastMediaControlIntent.CategoryForCast (APP_ID)) .Build(); mediaRouteButton.RouteSelector = mediaRouteSelector; myMediaRouterCallback = new MyMediaRouterCallback { OnRouteSelectedHandler = (router, route) => { Console.WriteLine("Route Selected: " + route.Name); var device = CastDevice.GetFromBundle(route.Extras); myCastListener = new MyCastListener(); var apiOptionsBuilder = new CastClass.CastOptions.Builder( device, myCastListener).SetVerboseLoggingEnabled(true); googleApiClient = new GoogleApiClientBuilder(this) .AddApi(CastClass.API, apiOptionsBuilder.Build()) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .Build(); googleApiClient.Connect(); }, OnRouteUnselectedHandler = (router, route) => { Console.WriteLine("Route Unselected: " + route.Name); }, RouteCountChangedHandler = newCount => { mediaRouteButton.Visibility = newCount > 0 ? ViewStates.Visible : ViewStates.Gone; } }; mediaRouter.AddCallback(mediaRouteSelector, myMediaRouterCallback, MediaRouter.CallbackFlagRequestDiscovery); }
/** * Attempt to connect to Google Play Services on activity start */ protected override void OnStart() { base.OnStart(); googleApiClient.Connect(); }
void LaunchReceiver() { try { var _castListener = new MyCastListener { ApplicationDisconnected = delegate (int statusCode) { Console.WriteLine ("Application disconnected - code {0}", statusCode); Teardown(true); } }; var apiOptionsBuilder = new CastClass.CastOptions.Builder(_selectedDevice, _castListener) .Build(); _apiClient = new GoogleApiClientBuilder(this, this, this) .AddApi (CastClass.API, apiOptionsBuilder) .Build(); _apiClient.Connect(); } catch (Exception e) { Console.WriteLine ("Failed LaunchReceiver - {0}", e); } }
protected override void OnCreate (Bundle savedInstanceState) { base.OnCreate (savedInstanceState); SetContentView (Resource.Layout.multi_moment_activity); var options = new PlusClass.PlusOptions.Builder().AddActivityTypes (MomentUtil.ACTIONS).Build (); mGoogleApiClient = new GoogleApiClientBuilder (this) .AddConnectionCallbacks(this) .AddOnConnectionFailedListener(this) .AddApi (PlusClass.API, options) .AddScope (PlusClass.ScopePlusLogin) .Build (); mListAdapter = new ArrayAdapter<string>( this, Android.Resource.Layout.SimpleListItem1, MomentUtil.MOMENT_LIST); mMomentListView = FindViewById<ListView>(Resource.Id.moment_list); mMomentListView.ItemClick += (sender, e) => { if (mGoogleApiClient.IsConnected) { var textView = e.View as TextView; var momentType = textView.Text; var targetUrl = MomentUtil.MOMENT_TYPES[momentType]; var target = new ItemScopeBuilder ().SetUrl(targetUrl).Build (); var momentBuilder = new MomentBuilder (); momentBuilder.SetType ("http://schemas.google.com/" + momentType); momentBuilder.SetTarget (target); var result = MomentUtil.GetResultFor (momentType); if (result != null) momentBuilder.SetResult (result); PlusClass.MomentsApi.Write (mGoogleApiClient, momentBuilder.Build ()).SetResultCallback<Statuses> (status => { switch (status.StatusCode) { case CommonStatusCodes.Success: Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_success), ToastLength.Short).Show (); break; case CommonStatusCodes.SuccessCache: Toast.MakeText(this, GetString (Resource.String.plus_write_moment_status_cached), ToastLength.Short).Show (); break; case CommonStatusCodes.SignInRequired: Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_auth_error), ToastLength.Short).Show(); mGoogleApiClient.Disconnect(); mGoogleApiClient.Connect(); break; default: Toast.MakeText (this, GetString (Resource.String.plus_write_moment_status_error), ToastLength.Short).Show(); Console.WriteLine ("Error when writing moments: " + status); break; } }); } }; mResolvingError = savedInstanceState != null && savedInstanceState.GetBoolean (STATE_RESOLVING_ERROR, false); var available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this); if (available != CommonStatusCodes.Success) { ShowDialog (DIALOG_GET_GOOGLE_PLAY_SERVICES); } if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) { ActionBar.SetDisplayHomeAsUpEnabled (true); } }
public void OnDisconnected() { Log.Debug ("LocClient", "Disconnected"); client = null; // If the client was disconnected too early if (currentRequest != ConnectionUpdateRequest.None) { client = CreateGoogleClient (); client.Connect (); } }
public void AddGeofences() { // Start a request to add geofences mRequestType = RequestType.Add; // Test for Google Play services after setting the request type if (!IsGooglePlayServicesAvailable) { Log.Error (Constants.TAG, "Unable to add geofences - Google Play services unavailable."); return; } // Create a new location client object. Since this activity implements ConnectionCallbacks and OnConnectionFailedListener, // it can be used as the listener for both parameters apiClient = new GoogleApiClientBuilder (this, this, this) .AddApi (LocationServices.API) .Build (); // If a request is not already underway if (!mInProgress) { // Indicate that a request is underway mInProgress = true; // Request a connection from the client to Location Services apiClient.Connect (); } else { // A request is already underway, so disconnect the client and retry the request apiClient.Disconnect (); apiClient.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 += (sender, e) => { mServerAuthCodeRequired.Set (true); if (mGoogleApiClient.IsConnected) { PlusClass.AccountApi.RevokeAccessAndDisconnect (mGoogleApiClient).SetResultCallback<Statuses> (result => { 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); } }