Skip to content

Instantly share code, notes, and snippets.

@zyc945
Created April 21, 2020 06:07
Show Gist options
  • Save zyc945/1953b3fe0270e531367ea2880084d1aa to your computer and use it in GitHub Desktop.
Save zyc945/1953b3fe0270e531367ea2880084d1aa to your computer and use it in GitHub Desktop.
report google play service status.
fun reportGooglePlayServiceStatus(context: Context) {
when (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context)) {
ConnectionResult.SUCCESS -> "success"
ConnectionResult.SERVICE_MISSING -> "service_missing"
ConnectionResult.SERVICE_UPDATING -> "service_updating"
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED -> "service_version_update_required"
ConnectionResult.SERVICE_DISABLED -> "service_disabled"
ConnectionResult.SERVICE_INVALID -> "service_invalid"
else -> "unknown"
}.let { result ->
logEvent(context, "isGooglePlayServicesAvailable", Bundle().apply {
putString("result", result)
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment