fun AppCompatActivity.checkSelfPermissionCompat(permission: String) =
ActivityCompat.checkSelfPermission(this, permission)
fun AppCompatActivity.shouldShowRequestPermissionRationaleCompat(permission: String) =
ActivityCompat.shouldShowRequestPermissionRationale(this, permission)
fun AppCompatActivity.requestPermissionsCompat(permissionsArray: Array<String>,
requestCode: Int) {
ActivityCompat.requestPermissions(this, permissionsArray, requestCode)
}
checkSelfPermissionCompat
: 권한 존재 여부 체크
shouldShowRequestPermissionRationaleCompat
: 사용자 권한거부 이력 체크
requestPermissionsCompat
: 권한이 없다면 실제 권한 요청
참고 구글 문서 https://developer.android.com/training/permissions/requesting?hl=ko
참고 구글 예제 https://github.com/googlearchive/android-RuntimePermissionsBasic/blob/master/
반응형
'메모 log (간단메모) > mobile' 카테고리의 다른 글
'stetcho' 디버깅 (0) | 2020.03.01 |
---|---|
'ForeignKey' 참고사항 (0) | 2020.02.22 |
navigation 이용시 label 변경 (0) | 2020.02.16 |
setHasOptionsMenu(true) (0) | 2020.02.08 |
isAssignableFrom (0) | 2020.02.08 |