Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check Google Play services version?

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?

like image 608
Arash Khoeini Avatar asked Sep 11 '13 09:09

Arash Khoeini


People also ask

What happens if I uninstall Google Play Services?

Google Play Game Service will be stopped if Google Play Service is stopped and uninstalled. You may also lose your progress in the game if you use it to sync and save your game data. Also Read: How to Check Phone Processor [Android, iOS] ?

What is Google Play Services on my phone?

Google Play services helps to ensure the security and reliability of an Android device, and keep devices updated with the latest security features. This includes: Google Play Protect, which can warn users if an app contains known malware.


1 Answers

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 )); 
like image 81
yital9 Avatar answered Sep 27 '22 22:09

yital9