+{"Name":"Google Play Services","Id":1356,"Alias":"googleplayservices","Description":"With Google Play services, your app can take advantage of the latest, Google-powered features such as Maps, Google+, and more, with automatic platform updates distributed as an APK through the Google Play store. This makes it faster for your users to receive updates and easier for you to integrate the newest that Google has to offer.\n\nThis component is only for Xamarin.Android applications that target Android 4.0 (API level 14) and higher. \n\n#### Google Technology\n* Google Play services provides you with easy access to Google services and is tightly integrated with the Android OS. Easy-to-use client libraries are provided for each service that let you implement the functionality you want easier and faster.\n\n#### Standard Authorization\n* All products in Google Play services share a common authorization API that leverages the existing Google accounts on the device. You and your users have a consistent and safe way to grant and receive OAuth2 access tokens to Google services.\n\n#### Automatic Updates\n* Devices running Android 2.23and newer and that have the Google Play Store app automatically receive updates to Google Play services. Enhance your app with the most recent version of Google Play services without worrying about your users\u0027 Android version.\n\nShowing a Map\n=============\n\nThis snippet shows how easy is to add a Map fragment to you app. **Additional setup is required please see** `GettingStarted` for more information.\n\n### MainActivity.cs\n\n```csharp\nusing Android.Gms.Maps;\n// ...\n\nprotected override void OnCreate (Bundle bundle)\n{\n\tbase.OnCreate (bundle);\n\n\t// add map fragment to frame layout\n\tvar mapFragment = new MapFragment ();\n\tFragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();\n\tfragmentTx.Add (Resource.Id.linearLayout1, mapFragment);\n\tfragmentTx.Commit ();\n\n\t// Set our view from the \"main\" layout resource\n\tSetContentView (Resource.Layout.Main);\n}\n```\n\nHow It Works\n============\n\n### The Google Play services client library\n\nThe client library contains the interfaces to the individual Google services and allows you to obtain authorization from users to gain access to these services with their credentials. It also contains APIs that allow you to resolve any issues at runtime, such as a missing, disabled, or out-of-date Google Play services APK. The client library has a light footprint, so it won\u0027t have an adverse impact on your app\u0027s file size.\n\nIf you want to access added features or products, you can upgrade to a new version of the client library as they are released. However, upgrading is not necessary if you don\u0027t care about new features or bug fixes. We anticipate more Google services to be continuously added, so be on the lookout for these updates.\n\n### The Google Play services APK\nThe Google Play services APK contains the individual Google services and runs as a background service in the Android OS. You interact with the background service through the client library and the service carries out the actions on your behalf. An easy-to-use authorization flow is also provided to gain access to the each Google service, which provides consistency for both you and your users.\n\nThe Google Play services APK is delivered through the Google Play Store, so updates to the services are not dependent on carrier or OEM system image updates. In general, devices running Android 2.2 (Froyo) or later and have the Google Play Store app installed receive updates within a few days. This allows you to use the newest APIs in Google Play services and reach most of the devices in the Android ecosystem (devices older than Android 2.2 or devices without the Google Play Store app are not supported).\n\n![The Google Play services APK on user devices receives regular updates for new APIs, features, and bug fixes.][1]\n\n### The benefits for your app\nGoogle Play services gives you the freedom to use the newest APIs for popular Google services without worrying about device support. Updates to Google Play services are distributed automatically by the Google Play Store and new versions of the client library are delivered through the Android SDK Manager. This makes it easy for you to focus on what\u0027s important: your users\u0027 experience.\n\n[1]: http://developer.android.com/images/play-services-diagram.png","Version":"22.0.0.0","Summary":"Give your apps more features to attract users on a wider range of devices.","QuickStart":"Requirements\n============\n\nIt is not necessary to manually manage the version of the Google Play Services client libary via the Android SDK manager. The Google Play Services component embeds metadata to identify what version of the Google Services client library it is bound to. When you add the component to your application, the correct version of the Google Play Services client library is downloaded and the component automatically binds to that, instead of the version that is installed by the Android SDK Manager.\n\n\nTo **test** your app when using the **Google Play services SDK**, you must use either:\n\n* A compatible Android device that runs Android 4.0 or higher and includes Google Play Store.\n* The **Android emulator** with an AVD that runs the **Google APIs** platform based on **API level 19**.\n\nIdeally, you should develop and test your app on a variety of devices, including both phones and tablets.\n\nGoogle Maps v2 API Key\n----------------------\n\nYou must [obtain a new API Key](https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key) for Google Maps v2, API keys from Google Maps v1 will not work. \n\nThe location of the debug.keystore file that Xamarin.Android uses depends on your platform:\n\n- **Windows Vista / Windows 7 / Windows 8**: `C:\\Users\\[USERNAME]\\AppData\\Local\\Xamarin\\Mono for Android\\debug.keystore`\n- **OSX** : `/Users/[USERNAME]/.local/share/Xamarin/Mono for Android/debug.keystore`\n\nTo obtain the SHA1 fingerprint of the debug keystore, you can use the `keytool` command that is a part of the JDK. This is an example of using `keytool` at the command-line:\n\n $ keytool -V -list -keystore debug.keystore -alias androiddebugkey -storepass android -keypass android\n\n\nShowing a Map\n=============\n\n### MainActivity.cs\n\n```csharp\nusing Android.Gms.Maps;\n// ...\n\nprotected override void OnCreate (Bundle bundle)\n{\n\tbase.OnCreate (bundle);\n\n\t// add map fragment to frame layout\n\tvar mapFragment = new MapFragment ();\n\tFragmentTransaction fragmentTx = this.FragmentManager.BeginTransaction();\n\tfragmentTx.Add (Resource.Id.linearLayout1, mapFragment);\n\tfragmentTx.Commit ();\n\n\t// Set our view from the \"main\" layout resource\n\tSetContentView (Resource.Layout.Main);\n}\n```\n\n### Adding the API Key to your application\n\nIt goes in your application\u0027s manifest, contained in the file AndroidManifest.xml. From there, the Maps API reads the key value and passes it to the Google Maps server, which then confirms that you have access to Google Maps data.\n\nIn `AndroidManifest.xml`, add the following element as a child of the `\u003capplication\u003e` element, by inserting it just before the closing tag `\u003c/application\u003e`\n\n```xml\n\u003capplication android:label=\"@string/app_name\"\u003e\n\t\t\u003c!-- Put your Google Maps V2 API Key here. This key will not work for you.--\u003e\n\t\t\u003c!-- See https://developers.google.com/maps/documentation/android/start#obtaining_an_api_key --\u003e\n\t\t\u003cmeta-data android:name=\"com.google.android.maps.v2.API_KEY\" android:value=\"YourKey\" /\u003e\n\u003cmeta-data android:name=\"com.google.android.gms.version\" android:value=\"@integer/google_play_services_version\" /\u003e\n\u003c/application\u003e\n```\n\nAdd the following elements to your manifest. Replace `com.example.mapdemo` with the package name of your application.\n\n```xml\n\u003cpermission\n android:name=\"com.example.mapdemo.permission.MAPS_RECEIVE\"\n android:protectionLevel=\"signature\"/\u003e\n\u003cuses-permission android:name=\"com.example.mapdemo.permission.MAPS_RECEIVE\"/\u003e\n```\n\n### Specifying additional permissions\n\nBesides permissions required by other parts of your application, you must add the following permissions to `AndroidManifest.xml` in order to use the Google Maps Android API:\n\n```xml\n\u003c!-- We need to be able to download map tiles and access Google Play Services--\u003e\n\u003cuses-permission android:name=\"android.permission.INTERNET\" /\u003e\n\u003c!-- Allow the application to access Google web-based services. --\u003e\n\u003cuses-permission android:name=\"com.google.android.providers.gsf.permission.READ_GSERVICES\" /\u003e\n\u003c!-- Google Maps for Android v2 will cache map tiles on external storage --\u003e\n\u003cuses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" /\u003e\n\u003c!-- Google Maps for Android v2 needs this permission so that it may check the connection state as it must download data --\u003e\n\u003cuses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" /\u003e\n\u003c!-- These are optional, but recommended. They will allow Maps to use the My Location provider. --\u003e\n\u003cuses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" /\u003e\n\u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n```\n\n### Requiring OpenGL ES version 2\n\nBecause version 2 of the Google Maps Android API requires OpenGL ES version 2, you must add a `\u003cuses-feature\u003e` element as a child of the `\u003cmanifest\u003e` element in `AndroidManifest.xml`\n\n```xml\n\u003c!-- Google Maps for Android v2 requires OpenGL ES v2 --\u003e\n\t\u003cuses-feature android:glEsVersion=\"0x00020000\" android:required=\"true\" /\u003e\n```\n\nTroubleshooting \n===============\n\nIn order to fix `java.lang.OutOfMemoryError: Java heap space` you will need to increase the **JavaMaximunHeapSize**, in order to do this you must edit the .csproj (Your Project File) in a\nXML/Text editor, and add\n\n\t\u003cPropertyGroup\u003e\n \u003cJavaMaximumHeapSize\u003e1G\u003c/JavaMaximumHeapSize\u003e\n \u003c/PropertyGroup\u003e\n\n* JavaMaximunHeapSize - This allows the overriding of the\n default java heapsize which is sometimes too low to compile\n some .jar files.","Hash":"920b00b0a9bd50b1014b5dedaaeeb208","TargetPlatforms":["android"],"TrialHash":null}
0 commit comments