
Learning to play with camera API of Android OS is fun, In this post, we will talk about android camera API and by the end of this article, you will be able to make an android application that can take a picture using default android camera app. And Display that in ImageView Widget. So we will be able to basically Capture & Display Image in Android ImageView.
- Open Android Studio and Create New App With Empty Activity
- Select The Target API as 23 or Above ( We Need to ask Run time Permission for Camera and Storage from the user ).
Since we need to use the Camera and gallery we need permission from the user to the user both camera and gallery. We need to specify, what are the resources that our application needs to function in the manifest file.
We need to Provide the file provider to be able to retrieve the path of the image that is taken by the camera. so let’s add the <provider> in Manifest File The final Manifest.xml file looks like below.
Now We need to write all the codes that implement logic to take an image as well as select the image from the gallery.
- galleryAddpic() method is used to send the broadcast to MediaStore. So that our captured image will appear in Gallery.
Leave a Reply