Varvara Kalinina
Varvara Kalinina

Reputation: 2063

How to get GoogleApiClient in Xamarin?

I want to implement something like this in my Android application that I'm developing in Xamarin but can not find a namespace in which the GoogleApiClient is. Can anybody help?

Upvotes: 10

Views: 8924

Answers (3)

Joe Perkins
Joe Perkins

Reputation: 170

It should be noted that the command "Install-Package Xamarin.GooglePlayServices.Location" also works for updating the Xamarin.GooglePlayServices. It will always fail if you try to use the UI to update the components.

Upvotes: 0

fukuda
fukuda

Reputation: 416

In addition to RobertN answer, it seems there were some naming/namespace changes in 27.0.0.0.

So here's an example that might help:

GoogleApiClient api = new GoogleApiClient.Builder (Application.Context, this, this)
    .AddApi (Android.Gms.Location.LocationServices.API)
    .Build ();

In the above code this means that the below interfaces are implemented:

  • Android.Gms.Common.Apis.GoogleApiClient.IConnectionCallbacks
  • Android.Gms.Common.Apis.GoogleApiClient.IOnConnectionFailedListener

Upvotes: 5

SushiHangover
SushiHangover

Reputation: 74184

GoogleApiClient is in the Android.Gms.Common.Apis namespace.

That namespace is in the "Xamarin.GooglePlayServices.Basement" assembly, but you do not install that directly.

So, assuming you are trying to access that in doing some Android Location/Map development, install this nuget:

Xamarin Google Play Services - Location

Xamarin.Android Bindings for Google Play Services - Location

One of the unique features of mobile applications is location awareness. Mobile users take their devices with them everywhere, and adding location awareness to your app offers users a more contextual experience. The location APIs available in Google Play services facilitate adding location awareness to your app with automated location tracking, geofencing, and activity recognition.

To install Xamarin Google Play Services - Location, run the following command in the Package Manager Console

PM> Install-Package Xamarin.GooglePlayServices.Location

Using clause:

using Android.Gms.Common.Apis;

Code:

var foo = GoogleApiClient ();

Upvotes: 13

Related Questions