Skip to content

Instantly share code, notes, and snippets.

@pedrovarela86
Last active April 25, 2020 23:06
Show Gist options
  • Save pedrovarela86/e341190621dc28745dbe677cb7cb851b to your computer and use it in GitHub Desktop.
Save pedrovarela86/e341190621dc28745dbe677cb7cb851b to your computer and use it in GitHub Desktop.
Función para verificar la disponibiliadad de Google Play Services
private var errorDialog: Dialog? = null
private fun checkGooglePlayServices(): Boolean {
val googleApiAvailability: GoogleApiAvailability = GoogleApiAvailability.getInstance()
val resultCode: Int = googleApiAvailability.isGooglePlayServicesAvailable(this)
if (resultCode != ConnectionResult.SUCCESS) {
if (googleApiAvailability.isUserResolvableError(resultCode)) {
if (errorDialog == null) {
errorDialog = googleApiAvailability.getErrorDialog(this, resultCode, 2404)
errorDialog?.setCancelable(false)
}
if (errorDialog?.isShowing == false) errorDialog?.show()
}
}
return resultCode == ConnectionResult.SUCCESS
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment