Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iosandroiddev/38b28d57d676a00921ac1bf379c98964 to your computer and use it in GitHub Desktop.
Save iosandroiddev/38b28d57d676a00921ac1bf379c98964 to your computer and use it in GitHub Desktop.
object GoogleApiAvailabilityHelper {
private const val REQUEST_CODE_GOOGLE_AVAILABILITY = 999
fun checkAvailability(activity: Activity): Boolean {
val googleApiAvailability = GoogleApiAvailability.getInstance()
val statusCode = googleApiAvailability.isGooglePlayServicesAvailable(activity)
val isResultSuccess = statusCode == ConnectionResult.SUCCESS
if (!isResultSuccess && googleApiAvailability.isUserResolvableError(statusCode)) {
googleApiAvailability.showErrorDialogFragment(activity, statusCode, REQUEST_CODE_GOOGLE_AVAILABILITY)
return false
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment