Skip to content

Instantly share code, notes, and snippets.

@simonbengtsson
Created January 23, 2020 20:28
Show Gist options
  • Save simonbengtsson/02386104a10a210371e0f144df11ebe4 to your computer and use it in GitHub Desktop.
Save simonbengtsson/02386104a10a210371e0f144df11ebe4 to your computer and use it in GitHub Desktop.
Check for Google Play services
class MainActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
if (checkGooglePlayServices()) {
startActivity(Intent(this, HomeActivity::class.java))
}
}
private fun checkGooglePlayServices(): Boolean {
val availability = GoogleApiAvailability.getInstance()
val resultCode = availability.isGooglePlayServicesAvailable(this)
if (resultCode != ConnectionResult.SUCCESS) {
availability.getErrorDialog(this, resultCode, 0).show()
return false
}
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment