0

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.

AL.
  • 36,815
  • 10
  • 142
  • 281
Renetik
  • 5,887
  • 1
  • 47
  • 66
  • No internet == no google play services update – Selvin Jan 19 '17 at 18:20
  • I am talking abut updating application through apk, when I create build that depends on new version of gps I have a problem because application cannot run and needs to update also google play services installation... But this is not always the case , sometimes I can upgrade gps to new version and it just works fine wit gps installation running on device I want to know if the new gps version like that now 10 requires update of gps on device.... – Renetik Jan 19 '17 at 18:23
  • I think you'll find the only simple solution here is to keep your devices up to date by connecting them to wifi. – mkasberg Jan 19 '17 at 18:41
  • No actually... the only solution is to not update or update test if it requires play services update and if yes revert back... Probably you did not understand that I am not in control of devices and they just will not be connected to outside wifi, or they will not have setup google account this devices are used like special scoring intranet devices, used in competition events. – Renetik Jan 19 '17 at 21:14

1 Answers1

1

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 its onResume() method. The check in onCreate() ensures that the app can't be used without a successful check. The check in onResume() 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.

Community
  • 1
  • 1
AL.
  • 36,815
  • 10
  • 142
  • 281
  • Well I don't know why you are not answering my question, what you write here I know and use for quite some time already... Did you read question and also comments under it ? I don't want to repeat myself everything is there. – Renetik Jan 20 '17 at 18:09
  • I've read it. *How can I know if it requires updating of installation of Google Play services on devices?* Use `isGooglePlayServicesAvailable`. You say you already know about it, but you still asked. @Selvin already mentioned that there is no way to update it without Internet connection. You asked (and was hoping) for a way to update when installing your APK. I answered the same. The point of my answer is to link relevant details that you didn't provide. StackOverflow is a public community. I added in answer so that it might be helpful not only to you, but to others as well. Keep an open mind. – AL. Jan 21 '17 at 05:17
  • If you still think that this is not a bit useful, just say so. I don't mind deleting it. But it would be great for you to put in an answer (any details you think would be useful) for your own post. Others might look into it in the future. AFAIC, there is no way to update GPS via installing your own app (which you already know). Good luck. Cheers. – AL. Jan 21 '17 at 05:19
  • At last it would be good ti know from somewhere that when I update to specific version it will not force my users to upgrade GPS, I thought there are some release notes where I can see this, or some other way of getting this information... We are now doing autoupdate of application so user just press button , update downloads and then I initiate apk update so user just have to press yes in update dialog... Its nice working but devices dont have google accounts setup and if I update to release that is incompatible with GPS on device we have problem especialy if this happens during competition. – Renetik Jan 22 '17 at 05:38
  • Your answer is good and useful for others, ironically I answered similar question some time ago with specific code example of way how to check for GPS because its quite complicated with all error handling... – Renetik Jan 22 '17 at 05:44