Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 802
Varvara Kalinina Avatar asked Oct 28 '15 12:10

Varvara Kalinina


People also ask

Is GoogleApiClient deprecated?

Yeah GoogleApiClient has been deprecated. Particularly for the authentication api, you now need to use GoogleSignInClient .

What is GoogleApiClient?

You can use the GoogleApiClient ("Google API Client") object to access the Google APIs provided in the Google Play services library (such as Google Sign-In, Games, and Drive).

What is xamarin essentials?

Xamarin. Essentials provides a single cross-platform API that works with any iOS, Android, or UWP application that can be accessed from shared code no matter how the user interface is created. See the platform & feature support guide for more information on supported operating systems.


2 Answers

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 ();
like image 151
SushiHangover Avatar answered Sep 17 '22 23:09

SushiHangover


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
like image 32
fukuda Avatar answered Sep 16 '22 23:09

fukuda