Avatar ·

How to check and request permissions in a Fragment on Android using Kotlin?

Hello everyone! I'm new to Android development in Kotlin, and I'm having trouble requesting permissions inside a Fragment. I've read many examples, but they mostly show how to do it from an Activity using `onRequestPermissionsResult`. When I try to call `requestPermissions()` from a Fragment, nothing happens, or the result goes to the Activity instead of the Fragment. Here is my simplified code. I have a Fragment that needs to access the camera. ```kotlin class CameraFragment : Fragment() { private lateinit var binding: FragmentCameraBinding override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { binding = FragmentCameraBinding.inflate(inflater, container, false) return binding.root } } ```