Builduing a Simple Flashlight App in Android Studio
In this post, you will learn how to create a simple flashlight app to enable or disable the phone's flashlight in android stuido using Java. For building the app, first, create a new project and add the power icon from vector assets in your drawable folder. Now, create two new drawable resource files that will be the background for our switch on and switch off button. Add the following code to the files: Code for switch on button: Code for switch off button: Once this is done, in the activity_main.xml file, create the layout for the app screen. Add the following code: The background of the image buttons are the switch_on and switch_off drawable files that we created earlier. Now, in the MainActivity.java class , add the following code: Here the Camera used is Camera (android.hardware) and not the graphics one. Now finally, in the AndroidManifest.xml file, add the permissions to allow access to the device's camera. <uses-permission android:name="android.permission