{"id":22521,"date":"2015-11-03T11:57:07","date_gmt":"2015-11-03T19:57:07","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=22521"},"modified":"2015-11-03T11:57:07","modified_gmt":"2015-11-03T19:57:07","slug":"new-improved-google-play-services-for-android","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/new-improved-google-play-services-for-android\/","title":{"rendered":"New &amp; Improved Google Play Services for Android"},"content":{"rendered":"<p>\t\t\t\t<img decoding=\"async\" class=\"alignright wp-image-22524\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Xamarin-Google-Play-Services-300x300.png\" alt=\"Xamarin Google Play Services Android\" width=\"125\" height=\"125\" \/> 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.<\/p>\n<p>This release also comes with\u00a0some\u00a0improvements to the Xamarin developer experience that we have brought to Google Play services for Android <a href=\"http:\/\/components.xamarin.com\/?search=Google+Play+Services\" target=\"_blank\">components<\/a> and <a href=\"https:\/\/www.nuget.org\/packages?q=xamarin+google+play+services\" target=\"_blank\">NuGets<\/a>.<\/p>\n<h2>Add What You Need<\/h2>\n<p>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,\u00a0we&#8217;ve followed Google&#8217;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.\u00a0For example, if you only need Google Analytics, you can install the <em>Google Play Services&mdash;Analytics<\/em>\u00a0component\/package without any excess baggage.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Xamarin-Google-Play-Services-Components-List.png\"><img decoding=\"async\" class=\"aligncenter wp-image-22536 size-full\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/Xamarin-Google-Play-Services-Components-List.png\" alt=\"Xamarin Google Play Services Components List\" width=\"774\" height=\"629\" \/><\/a><\/p>\n<h2>Much More Async \/ Await<\/h2>\n<p>The async \/ await pattern is incredibly useful for C# developers, so we&#8217;ve added more support for it.\u00a0There are many methods in Google Play services that return a <code class=\"EnlighterJSRAW\">PendingResult<\/code> instance, which is basically a reference to a <em>future<\/em> result.<\/p>\n<p>Previously you could choose to call the <code class=\"EnlighterJSRAW\">.Await()<\/code> method (not to be confused with the C# <code class=\"EnlighterJSRAW\">await<\/code> keyword) and block your code&#8217;s execution to wait for a <code class=\"EnlighterJSRAW\">Java.Lang.Object<\/code>. You would then have to know the proper type to use with the\u00a0<code class=\"EnlighterJSRAW\">.JavaCast&lt;TResult&gt; (..)<\/code>\u00a0call.<\/p>\n<p>With the <strong><em>300+<\/em><\/strong> new async versions of these methods, you can now <code class=\"EnlighterJSRAW\">await<\/code> a strongly typed result very easily:<\/p>\n<pre class=\"EnlighterJSRAW \">var placeBuffer = await PlacesClass.GeoDataApi.GetPlaceByIdAsync (googleApiClient, \"7\", \"12\");<\/pre>\n<p>Every method that returns <code class=\"EnlighterJSRAW\">PendingResult<\/code> now has an <em><strong>*Async<\/strong><\/em>\u00a0version (either on the class itself, or provided as an extension method).<\/p>\n<h2>Enumerable Data Buffers<\/h2>\n<p>There are a number of methods in the Google Play services API that return results in a <em>Data Buffer<\/em>\u00a0type of object.\u00a0In the past, these buffers contained no type information about the result objects they held\u00a0and were not enumerable, so you couldn&#8217;t do things like loop through them with <code class=\"EnlighterJSRAW\">foreach<\/code>.<\/p>\n<p>In the latest release, we&#8217;ve added <code class=\"EnlighterJSRAW\">IEnumerable<\/code> implementations so you can get the correctly typed results out in a much more .NET friendly way:<\/p>\n<pre class=\"EnlighterJSRAW\">foreach (IPlace place in placeBuffer) {\n    Console.WriteLine (place.Description);\n}\n<\/pre>\n<h2>More Samples<\/h2>\n<p>Along with all the new Google Play services <a href=\"http:\/\/components.xamarin.com\/?search=Google+Play+Services\" target=\"_blank\">components<\/a>, we&#8217;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\u00a0<a href=\"https:\/\/github.com\/xamarin\/monodroid-samples\" target=\"_blank\">new\u00a0Android samples<\/a> we have available for you to try out.\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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\u00a0some\u00a0improvements to the Xamarin developer experience that we have brought to Google Play services for Android components and NuGets. Add What You Need [&hellip;]<\/p>\n","protected":false},"author":560,"featured_media":22524,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[5],"class_list":["post-22521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-android"],"acf":[],"blog_post_summary":"<p>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\u00a0some\u00a0improvements to the Xamarin developer experience that we have brought to Google Play services for Android components and NuGets. Add What You Need [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/22521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/560"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=22521"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/22521\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=22521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=22521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=22521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}