I am trying to disable the camera launch button in my app if the camera intent cannot be handled by the device. I am targeting Android R (11). The code that I have so far is this
val packageManager: PackageManager = requireActivity().packageManager
val captureImage = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
if (captureImage.resolveActivity(packageManager) == null) {
isEnabled = false
}
The issue that I am having is that when I implement this code the camera launch button is always disabled even on devices that support it. I am not sure why it is doing this other than that maybe I need to add package-visibility
into the manifest file but I am unsure how that all works as the documentation isn't the best when it comes to examples. Any help or guidance would be greatly appreciated.