Created
August 2, 2023 18:10
-
-
Save UtkuGlsvn/391488f606d3afeeb86d0962aff8d14d to your computer and use it in GitHub Desktop.
Android multi permission function
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 checkNotificationPermission(): Boolean { | |
val permissions = arrayOf( | |
Manifest.permission.POST_NOTIFICATIONS, | |
Manifest.permission.ACCESS_COARSE_LOCATION | |
) | |
val isAllPermissionsGranted = permissions.all { | |
this.checkSelfPermission(it) == PackageManager.PERMISSION_GRANTED | |
} | |
if (!isAllPermissionsGranted) { | |
this.requestPermissions(permissions, 1) | |
} | |
return isAllPermissionsGranted | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
val isPermissionGranted = checkNotificationPermission()