Reputation: 6373
I want to upgrade Google Play Services to version 10 in my dependencies in gradle, so I keep application dependencies up to date.
How can I know if it requires updating of installation of Google Play services on devices? Some of the devices are not updated while offline and they don't have access to internet for specific reasons.
Upvotes: 0
Views: 287
Reputation: 37778
In order for you to check for the current GPS version on the device, you can call GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this)
:
Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.
Checking is advised to be made in both onCreate()
and onResume
, as per this Firebase doc:
Apps that rely on the Play Services SDK should always check the device for a compatible Google Play services APK before accessing Google Play services features. It is recommended to do this in two places: in the main activity's
onCreate()
method, and in itsonResume()
method. The check inonCreate()
ensures that the app can't be used without a successful check. The check inonResume()
ensures that if the user returns to the running app through some other means, such as through the back button, the check is still performed.If the device doesn't have a compatible version of Google Play services, your app can call
GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
to allow users to download Google Play services from the Play Store.
PS: The documentation is from Firebase, but the contents are applicable, so I figured I can use this one.
I think the accepted answer here by @MarcinOrlowski is a good way to handle such scenarios.
Unfortunately though, there is no way for you to update Google Play Services to match what you set from the installation of your app.
IMHO, this is to be considered as a security feature, since being able to update a different app, by installing a different app is a risk. Plus, in Android, it is really important that the power or control on what happens in the device should depend only on the user.
Upvotes: 1