To make a Flashlight app for android in Sketchware is very easy and simple. Just follow the steps given below:
Step 1 - Creat a new project Flashlight (you can also add flashlight with logo if you want), Drag Linear(V) to the screen, Set it's width to match_parent, Set gravity to center_horizontal and center_vertical.
Drag ImageView to the screen as ImageView1, Set it's width and height to 100, and scale type to FIT_XY.
Step 2 - Go to option and using Image manager add two images ic_flash_on_black and ic_flash_off_black.
Step 3 - Set ic_flash_off_black as the image of ImageView1 as shown in the picture.
Step 4 - Go to option, in Library manager switch on AppCompat and Design.
Step 5 - Add a Camera component.

Step 6 - Add two Variables: flashLightStatus and hasCameraFlash as shown in the picture.
Step 7 - Add two MoreBlock: flashLightOn and flashLightOff.
Step 8 - Go to onCreate event, use add source directly block and put the following code:
hasCameraFlash = getPackageManager(). hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);
Step 9 - In More Block flashLightOn, use add source directly block and put the following code:
android.hardware.camera2.CameraManager cameraManager = (android.hardware.camera2.CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String cameraId = cameraManager.getCameraIdList()[0]; cameraManager.setTorchMode(cameraId, true);
flashLightStatus = true; imageview1.setImageResource(R.drawable.ic_flash_on_black); } catch (android.hardware.camera2.CameraAccessException e) { }
Step 10 - In More Block flashLightOff, use add source directly block and put the following code:
android.hardware.camera2.CameraManager cameraManager = (android.hardware.camera2.CameraManager) getSystemService(Context.CAMERA_SERVICE);
try {
String cameraId = cameraManager.getCameraIdList()[0]; cameraManager.setTorchMode(cameraId, false);
flashLightStatus = false; imageview1.setImageResource(R.drawable.ic_flash_off_black); } catch (android.hardware.camera2.CameraAccessException e) { }
Step 11 - In ImageView1 onClick event, add blocks as shown in the picture above.
Step 12 - Now run and flashlight app install is completed.
This is how you make a flashlight app for tablets and mobile phones.
This is how you make a flashlight app for tablets and mobile phones.
For more sketchware tutorials pdf and sketchware help...