Hello Guys  Today you seeing Awesome Flash light app In Sketchware 

So let's start 

1. Open a new project in sketchware app

Add 1 imageview in xml area and 2 button 

Note:button1 text "On" and butto2 text "Off"

See this 



2. Add 2 image

Download this image 

And this 


Flash on image name : ic_flash_on_black

And flash light off image name : ic_flash_off_black

3.create camera component name : cam 

And timer component name : t

Also create boolean variable 
hasCameraFlash
And 
flashLightStatus

Create number variable name n

Imageview1 on click event this image below


4.move to login area using if else blocks use this image below

I used GradientDrawable simple code 

5.create 2 more block  name: flashLightO and flashLightOff

Flash Light On more blocks I used this code below


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) { }



Then flash light off more blocks 

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) { }

And lastly I used this blocks on sos button clicked this image 


And when stop button clicked this image below




Now click run

Post a Comment

Previous Post Next Post