NOTE : If you want to run app in background just open Flashlight torch - Bright LED, which turn on automatically, Press home button and Flashlight Torch will be minimised.
If you encounter any issue while turning off.Then simply open the app Press Back button on your phone. Light will be off.
Here is the code How it works :
------------->>>>>>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnSwitch = (ImageButton) findViewById(R.id.btnSwitch);
// get the camera
getCamera();
toggleButtonImage();
btnSwitch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isFlashOn)
{
turnOffFlash();
} else
turnOnFlash();
}
}
});
}
// Get the camera
private void getCamera() {
if (camera == null) {
try {
camera = Camera.open();
params = camera.getParameters();
} catch (RuntimeException e) {
Log.e("Camera Failed to Open", e.getMessage());
}
}
}
// Turning On flash
private void turnOnFlash() {
if (!isFlashOn) {
if (camera == null || params == null) {
return;
}
params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
isFlashOn = true;
// changing button/switch image
toggleButtonImage();
}
}
// Turning Off flash
private void turnOffFlash() {
if (isFlashOn) {
if (camera == null || params == null) {
return;
}
params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(params);
camera.stopPreview();
isFlashOn = false;
// changing button/switch image
toggleButtonImage();
}
private void toggleButtonImage(){
if(isFlashOn){
btnSwitch.setImageResource(R.drawable.btn_switch_on);
}else{
btnSwitch.setImageResource(R.drawable.btn_switch_off);
}
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onRestart() {
super.onRestart();
}
@Override
protected void onResume() {
super.onResume();
if(hasFlash)
turnOnFlash();
}
@Override
protected void onStart() {
super.onStart();
getCamera();
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(params);
camera.stopPreview();
isFlashOn = false;
if (camera != null) {
camera.release();
camera = null;
}
Log.d("Camera","Back Pressed");
}
@Override
protected void onStop() {
super.onStop();
}
}
********************************************************
This is the codes Flashligh Torch - Bright LED is using !
If you need your app custom designed for you. Just Drop me mail with Subject :
"Modify Flashlight App for me"
Give your two pics for light_on and light_off Images!
Thanks !
We do not host Flashlight Torch - Bright LED on our servers. We did not scan it for viruses, adware, spyware or other type of malware. This app is hosted by Galad and passed their terms and conditions to be listed there. We recommend caution when installing it.
The APK Download link for Flashlight Torch - Bright LED is provided to you by apps112.com without any warranties, representations or guarantees of any kind, so access it at your own risk.
If you have questions regarding this particular app contact the publisher directly. For questions about the functionalities of apps112.com contact us.
| ||||
Downloads: 4 | ||||
Updated At: 2024-04-22 14:59:10 | ||||
Publisher: Prabhakar Pandey | ||||
Operating System: Android | ||||
License Type: Free |