How to Check Google Play Services Version

How to check Google Play services version?

I found simple solution:

int v = getPackageManager().getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0 ).versionCode;

But versionCode is deprecated in API 28, so you can use PackageInfoCompat:

long v = PackageInfoCompat.getLongVersionCode(getPackageManager().getPackageInfo(GoogleApiAvailability.GOOGLE_PLAY_SERVICES_PACKAGE, 0 ));

How to find google play service version in Android Studio?

you should update google play services repository in sdk manager:

Sample Image

How can I determine the version of Google Play services?

You have the right idea by checking to make sure you do not have any updates.

The easiest way to check is simply when you have the latest downloaded in the Android SDK(locally).

I am using Mac OSX:

~/android-sdk/extras/google/m2repository/com/google/android/gms/play-services/

If you look where you have YOUR-ANDROID-SDK/extras/google/m2repository/com/google/android/gms/play-services/, you will see all the versions downloaded that you have.

The latest one being 6.5.87. (compile 'com.google.android.gms:play-services:6.5.87')

For you, the directory path on Windows would be:

C:\Users\Leila001\AppData\Local\Android\extras\google\m2repository\com\google\android\gms\play-services

How to check version of google play services in firebase app

During app initialization, your code should call GoogleApiAvailability.makeGooglePlayServicesAvailable().
Example use in onCreate() of main Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

GoogleApiAvailability.getInstance().makeGooglePlayServicesAvailable(this)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
Log.d(TAG, "onComplete: Play Services OKAY");
} else {
// Show the user some UI explaining that the needed version
// of Play Services could not be installed and the app can't run.
}
}
});

...
}

How to check the whether the android device has google play services running on 10.2 or greater

SmsRetrieverClient follows the newer GoogleApi connection pattern so you shouldn't have to worry about the version compatibility as the underlying framework handles all the resolution for you.

It may actually be better UX to specifically handle the failure case as well by adding listeners to these Task-returning API calls (https://developers.google.com/android/reference/com/google/android/gms/tasks/Task) instead of checking for availability beforehand.

No need to manually check Google Play Services version anymore?

Ok so I'll answer my own question after a quick test. I temporarily removed the checks that made sure Google Play Services was available and the correct version. Then installed the app on an emulator without Google Play Services and when I try to use the LocationServices API I get a sticky headsup notification saying:

[app name] won't run unless you update Google Play Services.

So I guess it's safe to remove the checks.

Worth noting is that it seems the listeners (Success/Failure/Complete) are not called unless the user actually interacts with the notification, if they for example just press something else in your apps UI, the listeners were not called.



Related Topics



Leave a reply



Submit