Question: 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?

Answer: 
```
int apkVersion = GoogleApiAvailability.getInstance().getApkVersion(getContext());

```

will get the same result as:

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

```

But the second one needs to be put inside a try-catch.
Updated (2019.07.03) Kotlin version:

```
class GooglePlayServicesUtil {

    companion object {

        private const val GOOGLE_PLAY_SERVICES_AVAILABLE_REQUEST = 9000

        fun isGooglePlayServicesWithError(activity: Activity, showDialog: Boolean): Boolean {
            val status = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity)
            return if (status != ConnectionResult.SUCCESS) {
                if (showDialog) {
                    GoogleApiAvailability.getInstance().getErrorDialog(activity, status, GOOGLE_PLAY_SERVICES_AVAILABLE_REQUEST).show()
                }
                true
            } else {
                false
            }
        }

    }

}

```