Google Play services is an Android library whose goal is to provide:
If I were to use it (for instance because I want Google+ sign-in), what would happen to users whose device does not have Google Play? (Nook, Cyanogenmod, China Mobile, old devices, maybe Huawei?, etc)
QUESTION: Will my app become incompatible with such devices? Will it be displayed as compatible but then crash, or not work?
Is there a best practice to keep this in mind when using Google Play services?
To update Google Play Services on your Android device, head to the "Apps & Notifications" menu in your settings. Google Play Services let your Android apps connect to the internet and communicate with Google. Updating Google Play Services can fix app issues, and help your Android device run faster.
Google Play Services are an essential part of the Android operating system. They allow many apps, including third-party apps and games, to exchange information with Google. This can include getting directions from Google Maps, making a Google search, signing into your Google account, and more.
GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
is deprecated!
Use:
GoogleApiAvailability api = GoogleApiAvailability.getInstance(); int code = api.isGooglePlayServicesAvailable(activity); if (code == ConnectionResult.SUCCESS) { // Do Your Stuff Here } else { AlertDialog alertDialog = new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle).setMessage( "You need to download Google Play Services in order to use this part of the application") .create(); alertDialog.show(); }
If the feature from Google Play Services is essential for your app there would be no way to get your App working.
You can check if the services are enabled from within your app with GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
which returns ConnectionResult.SUCCESS
if Play Services is available.
You can now try to convince the user to install it (if possible) or disable the feature that is using the service.
As the Google Play Services is not a feature declared in the manifest your app should install fine on any device but may crash later on if you are using the APIs without checking if they are available.
You can try the behaviour with the emulator. Just create an AVD without the Google APIs and put your App on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With