November 3rd, 2015

New & Improved Google Play Services for Android

Xamarin Google Play Services Android The latest Google Play services 8.1 for Android release brings some exciting new APIs, such as Barcode and Face detection, as well as simplified management of your sessions.

This release also comes with some improvements to the Xamarin developer experience that we have brought to Google Play services for Android components and NuGets.

Add What You Need

Previously, we shipped bindings to the entire Google Play services library in a single package, which has become increasingly large over time and resulted in bigger app sizes. Now, we’ve followed Google’s lead of splitting up the bindings into many smaller libraries so that you can choose only the bits you need, producing a smaller binary along the way. For example, if you only need Google Analytics, you can install the Google Play Services—Analytics component/package without any excess baggage.

Xamarin Google Play Services Components List

Much More Async / Await

The async / await pattern is incredibly useful for C# developers, so we’ve added more support for it. There are many methods in Google Play services that return a PendingResult instance, which is basically a reference to a future result.

Previously you could choose to call the .Await() method (not to be confused with the C# await keyword) and block your code’s execution to wait for a Java.Lang.Object. You would then have to know the proper type to use with the .JavaCast<TResult> (..) call.

With the 300+ new async versions of these methods, you can now await a strongly typed result very easily:

var placeBuffer = await PlacesClass.GeoDataApi.GetPlaceByIdAsync (googleApiClient, "7", "12");

Every method that returns PendingResult now has an *Async version (either on the class itself, or provided as an extension method).

Enumerable Data Buffers

There are a number of methods in the Google Play services API that return results in a Data Buffer type of object. In the past, these buffers contained no type information about the result objects they held and were not enumerable, so you couldn’t do things like loop through them with foreach.

In the latest release, we’ve added IEnumerable implementations so you can get the correctly typed results out in a much more .NET friendly way:

foreach (IPlace place in placeBuffer) {
    Console.WriteLine (place.Description);
}

More Samples

Along with all the new Google Play services components, we’ve included samples in each to help you better understand how to use the APIs. Be sure to update to the latest release of Google Play services today! Questions? Check out all of the new Android samples we have available for you to try out.

Category
Developers
Topics
Android

Author

0 comments

Discussion are closed.