Android Flashlight Torchlight Tutorial

Nowadays, all smart phones have torchlight or flashlight capability which come with the camera. The torchlight make the camera able to capture photos and make us able to viewing the objects in the dark environment. It is a very good features and provide the good user experience to the smart phones user. In this tutorial, I will give you some tutorial on how to create a flashlight application in android studio.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “FlashLightExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Edit activity_main.xml layout

In activity_main.xml add two button in the layout. The first button is turn on the flash light while the second button is turn off the flash light.

Edit class

Go to your and copy paste the following code. hasFlash boolean is to indicate the android device support flash light anot.

Run your Project

Now, you can run your project in your smartphone to test out the flash light.

(Android Flashlight Torchlight)

Source Code

(Visited 716 times, 1 visits today)

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

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