I am trying to use a camera on my android. the user will be prompt for the permission of the camera. previously I used startActivityForResult and onRequestPermissionRequest for them. recently I found out that they are deprecated, so I'm trying out with registerForActivity. I managed to change to startActivity but I'm stuck at the permission request. I am wondering do I have to create another permissionlauncher or can I do the permission inside my resultlauncher.

```
    companion object{
        private const val CAMERA_PERMISSION_CODE = 1
        private const val CAMERA_REQUEST_CODE = 2 
    }
val checkpermission = Manifest.permission.CAMERA

        var resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){ result ->
                if (result.resultCode == Activity.RESULT_OK) {
                    val data: Intent? = result.data
                    val DP: Bitmap = data!!.extras!!.get("data") as Bitmap
                    val image = findViewById<ImageView>(R.id.imageButtonVerifyPhoto)
                    image.setImageBitmap(DP)
                }

            }

        val permissionLauncher = registerForActivityResult(ActivityResultContracts.RequestPermission()){
                isGranted ->
            if(isGranted){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                resultLauncher.launch((intent))
                Toast.makeText(this,"Permission is tested", Toast.LENGTH_SHORT).show()
            }else{
                Toast.makeText(this,"Permission is denied",Toast.LENGTH_SHORT).show()
            }

        }
        var cameraButton = findViewById<Button>(R.id.buttonRetakePhoto) // can change later

        cameraButton.setOnClickListener {
            if(ContextCompat.checkSelfPermission(
                    this,
                    checkpermission
                ) == PackageManager.PERMISSION_GRANTED
            ){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                resultLauncher.launch(intent)

            }else{
                permissionLauncher.launch(checkpermission)
            }
        }

    }

```

below is my previous code for the onRequestPermission

```
    override fun onRequestPermissionsResult(
        requestCode: Int,
        permissions: Array<out String>,
        grantResults: IntArray
    ) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
        if(requestCode == CAMERA_REQUEST_CODE){
            if(grantResults.isNotEmpty()&& grantResults[0] == PackageManager.PERMISSION_GRANTED){
                val intent = Intent(MediaStore.ACTION_IMAGE_CAPTURE) 
                startActivityForResult(intent, CAMERA_REQUEST_CODE)
            }else{
                Toast.makeText(this,"Permission is denied",Toast.LENGTH_SHORT).show()
            }
        }
    }

```