Android Camera App Tutorial – Create a Simple Camera App

Hello friends, so here is a new Android Camera App Tutorial. In this tutorial we will create a simple Android Camera App. So lets begin. Creating Project for Android Camera App Tutorial This is so simple …

android camera app tutorial

Hello friends, so here is a new Android Camera App Tutorial. In this tutorial we will create a simple Android Camera App. So lets begin.

Creating Project for Android Camera App Tutorial

  • This is so simple open Android Studio and create a new project.
  • Now finish the things and you will get your MainActivity.
  • In this time we will try to make User Interface looks good.

Designing UI

  • I am creating a simple Button at the bottom of the activity. As you can see below.
android camera app tutorial
activity_main.xml
  • I have used font-awesome for the camera icon. So lets first learn how can you add font awesome to your android project.

Adding Font Awesome to Your Android Project

android camera app tutorial
Creating Assets

Creating Main Activity Layout

  • As you can see we have a single button at the bottom of our main activity.
  • Over the button we will see the image that would be captured with our app.
  • So we need an ImageView and a Button for this Android Camera App Tutorial’s main activity.
  • Go to activity_main.xml
  • And copy the following code

  • As you can see in Button tag I have defined a string. So go to your strings.xml file and add the following code

  • The initial value is the camera icon which I got from font awesome cheatsheet.
  • Now see the background property of our android button. I have given a drawable resource there. So Inside your drawable folder create a new xml file named button.xml
  • Add the following code inside that file.

  • Thats it for the layout part. Now lets move to the coding part.

Coding MainActivity.java

  • Go to your MainActivity.java file

  • We have declared instances for our button and imageview.
  • Lets initialize them first in our onCreate method.

  • Because we are using an external font we will need to set TypeFace for our button.

  • Now we will create a new method to open our camera.

  • We will call our open camera method on button click.
  • So add an onClickListener to your button.

  • Finally we will override the onActivityResult method to get the image.

  • The final code for MainActivity.java would be

  • Now execute your project.
  • Because It is using camera so the device must have camera, or I recommend you to run in your mobile phone.
  • And yes you can download the source code for this android camera app tutorial from below.

[easy_media_download url=”https://dl.dropboxusercontent.com/s/rm3kruvvpeha7n9/android-camera-app-tutorial.zip?dl=0″ text=”Download Source”]

So thats all for this Android Camera App Tutorial friends. In the next tutorials we will create some more complex camera applications on android. 🙂

Hi, my name is Belal Khan and I am a Google Developers Expert (GDE) for Android. The passion of teaching made me create this blog. If you are an Android Developer, or you are learning about Android Development, then I can help you a lot with Simplified Coding.

Expand Your Knowledge: Next Tutorial Picks

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x