Using a Camera Intent
The basic process to take a photo is relatively straightforward: You launch an external camera app, the user takes a photo, and then you update the crime with the path to the new file. To implement this, you are once again going to rely on the Activity Results API.
This time you are going to use the ActivityResultContracts.TakePicture() contract. It takes in a Uri, which will be generated by the FileProvider class using a File you will create. Once the user is finished taking the photo, the contract does not return that same Uri. Instead, it returns a Boolean telling you whether an image was saved to the file.
Create a class property on CrimeDetailFragment named takePhoto and initialize it using the Activity ...
Get Android Programming: The Big Nerd Ranch Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.