Created
November 27, 2017 15:25
-
-
Save about36km/2ece1015303bbb5c58c722441f2dc294 to your computer and use it in GitHub Desktop.
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
| private fun checkPermission() { | |
| if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { | |
| ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_COARSE_LOCATION), 9999) | |
| } | |
| } | |
| override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
| if (requestCode != 9999) { | |
| super.onRequestPermissionsResult(requestCode, permissions, grantResults) | |
| return | |
| } | |
| if (grantResults.any { it != PackageManager.PERMISSION_GRANTED }) { | |
| finish() | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment