capture image from camera android source code

hello, android developer once again welcomes back to another android app development tutorial in this article here I am going to show you to capture an image using your won application on a device. every device contains a default camera application if the camera is not the major part of your application you can use the inbuilt camera application on a device.so here in this article, I’m going to share with you how to use an inbuilt camera app to capture an image so let’s start.

how to create

follow the step by step method to create camera activity in android studio. also, I will prove to you the source code bellow. if you haven’t installed an android studio yet, go ahead and install an android studio before you begin.

  1. first, open an android studio and click on start a new Android Studio Project.
  2. let’s give the project name is “camera activity” leave the company domain as it is and click on the Next button.
  3. default it select phone and tablet leave as it is and now select the minimum SDK then click on next.
  4. next screen select blank activity template and then click next.
  5. now click on finish button and your application will be auto-generated for you.

add some
First, we have to Add this line inside AndroidManifest.xml of Android Studio for permissions to create the Camera application.

now open activity_main.xml file from the \res\layout folder path. then copy the activity_main.xml write the code like as shown below.

XML (activity_main.xml)

android studio code of Android Camera app

Add following code inside MainActivity.java of Android Studio:

JAVA (MainActivity.java)

now run the app and you will get the output as shown in the screenshot.

Leave a Reply

Your email address will not be published. Required fields are marked *