How to check Google Play services version?

前端 未结 12 1179
走了就别回头了
走了就别回头了 2020-11-28 03:44

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

12条回答
  •  感情败类
    2020-11-28 03:58

    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
                }
            }
    
        }
    
    }
    

提交回复
热议问题