Created
July 29, 2020 06:09
-
-
Save dyazincahya/5e1ae4e0b84785ea4ebdf44f4381a091 to your computer and use it in GitHub Desktop.
Sample code for get permission on android kotlin
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 xPermission() { | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
if (ActivityCompat.checkSelfPermission( | |
this, | |
Manifest.permission.READ_SMS | |
) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission( | |
this, | |
Manifest.permission.SEND_SMS | |
) != PackageManager.PERMISSION_GRANTED | |
) { | |
ActivityCompat.requestPermissions( | |
this, | |
arrayOf(Manifest.permission.READ_SMS, Manifest.permission.SEND_SMS), | |
0 | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment