registerForActivityResult 대신 rememberLauncherForActivityResult 을 활용하여 권한요청을 작성하면 됩니다.

@Preview
@Composable
fun PermissionTestInCompose() {
    val launch = rememberLauncherForActivityResult(
        contract = ActivityResultContracts.RequestPermission(),
        onResult = {

        })

    Button(onClick = {
        launch.launch(
            Manifest.permission.CAMERA
        )
    }) {

    }
}

 

https://github.com/sarang628/ComposePermissionTest

 

GitHub - sarang628/ComposePermissionTest

Contribute to sarang628/ComposePermissionTest development by creating an account on GitHub.

github.com

 

'Android > Compose' 카테고리의 다른 글

[compose] lifecycle  (0) 2024.07.28
[compose] RatingBar 만들기  (0) 2024.07.28
[compose] 텍스트 접고 펼치는 ExpandableText 만들기  (0) 2024.07.27
[compose] ConstraintLayout  (0) 2024.07.26

+ Recent posts