MikeOx
MikeOx

Reputation: 177

It's possible to programatically update Google Play Services?

I'm developing an App that needs Google play services updated to get current location(geolocation), if it's not updated it doesn't work properly, users that will use my app maybe don't know how to update it so I want to know if I can update Google play services to the last version or to "X" version programatically. I have this to check version but I can't find the way to update google play services:

 private void checkGoogleServicesVersion(){
    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo("com.google.android.gms", 0);
        Log.i("MAINA"," GMS version: "+packageInfo.versionName+" "+packageInfo.versionCode);

        if (packageInfo.versionCode < 9400000){

            // UPDATE GOOGLE PLAY SERVICES
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
}

Pd: It's a private app, the users don't even own the device so I shouldn't have security restrictions, I just want to make the app the easier as I can to the user, if this is not possible I would know a way to make easy to the user to update it.

Upvotes: 0

Views: 935

Answers (1)

Fabian Bettag
Fabian Bettag

Reputation: 810

For obvious security reasons this should not be possible.

If you could update any installed Application or Service, you could possibly influence the stability of the system.

Maybe some other Apps got dependencies to a specific Version, which you'd break by changing the Version.

Another reason could be that you can only use a newer Version after you agreed to updated Terms and Conditions. And the User might not want to agree to those and didn't update intentionally.

That's the reasoning. Technically the system won't allow you to start an Update. You could download an arbitrary APK and ask the User to install that (Amazon does that for their Video Service App).

But you might want to find a Fallback solution for PlayServices Versions that are lower than your requirements.

Upvotes: 1

Related Questions