Created
January 23, 2020 20:28
-
-
Save simonbengtsson/02386104a10a210371e0f144df11ebe4 to your computer and use it in GitHub Desktop.
Check for Google Play services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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