I’m working through the book, and encountered the following issue. When I attempt to enable/disable the crimeCamera button, I use the code highlighted in the middle of page 357:
val captureImageIntent = takePhoto.contract.createIntent(requireContext(), null)
crimeCamera.isEnabled = canResolveIntent(captureImageIntent)
When run, my program throws an exception:
java.lang.NullPointerException: Parameter specified as non-null is null
… and the trace identifies the first line above as the culprit. I was unable to find the issue debugging, and after commenting out the enable/disable code, I was able to complete the rest of the chapter without a hitch: the camera works, the image is stored, the thumbnail is displayed, etc.
Any advice for a workaround? I’d still like this code to work if it is possible.