Skip to content

Instantly share code, notes, and snippets.

@oakkub
Created January 11, 2018 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save oakkub/093d51d1580e4552b477d87e82ddc337 to your computer and use it in GitHub Desktop.
Save oakkub/093d51d1580e4552b477d87e82ddc337 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