How to check Google Play services version?

Arash Khoeini picture Arash Khoeini · Sep 11, 2013 · Viewed 87.6k times · Source

In my application, I need to check Google Play services version (which is installed in user's device). Is it possible ? And if yes, how can I do that? I searched Google but I could not find anything!

Answer

yital9 picture yital9 · Mar 6, 2014

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 ));