flashlight

Flashlight (Torch) is opening but not closing

匆匆过客 提交于 2019-12-23 05:27:13
问题 Following is the code which I used for opening Torch and closing it. But when I close it, it crashes. LogCat says " Runtime Exception : Fail to connect to camera service "! + hasFlash is not getting any value and is throwing Nullpointer exception. (I'm using it to check if the flash is present or not.) What am I doing Wrong? boolean hasFlash = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); if(hasFlash==true) { if(s.equalsIgnoreCase("FlashLight On") || s

flash light is not turned on

家住魔仙堡 提交于 2019-12-22 20:43:03
问题 This is my source code for barcode snanner which I post again. I edited my code. The problem is, when i run app, flash light is not turned on automatically. I added permission in manifest file, but flash light did not turn on. please help me where is the problem? I am using HTC wIldfire s mobile. public final class CameraManager { private static final String TAG = CameraManager.class.getSimpleName(); private static final int MIN_FRAME_WIDTH = 240; private static final int MIN_FRAME_HEIGHT =

Flash Torch on Google Nexus 5

北慕城南 提交于 2019-12-21 19:56:15
问题 after reading all the posts of the other users with the same problem I was able to create a simple working app for turning on flash light on my Nexus 5, this is the "OnCreate()" method: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Camera mCamera; SurfaceView preview; mCamera = Camera.open(); Parameters params = mCamera.getParameters(); params.setFlashMode(Parameters.FLASH_MODE_TORCH); mCamera

Setting Parameters.FLASH_MODE_TORCH doesn't work on Droid X 2.3

五迷三道 提交于 2019-12-21 19:27:08
问题 I am writing an app that sets the flash mode to torch. I have been testing the application on my Droid X, and the LED light does not come on. I tried it on a Droid Incredible and it worked fine. I can't figure out what the problem is. Here is part of my code for turning on torch mode. Camera mCamera = Camera.open(); Camera.Parameters params = mCamera.getParameters(); if(params.getFlashMode() != null){ params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); } mCamera.setParameters(params); I

Flashlight control in Marshmallow

为君一笑 提交于 2019-12-20 18:28:21
问题 I have a problem regarding the camera in the most recent Marshmallow build, more specifically the flashlight. On any pre-Marshmallow version all I need to do to turn the flash on/off was the following: private void turnFlashOn(final Camera camera, int flashLightDurationMs) { if (!isFlashOn()) { final List<String> supportedFlashModes = camera.getParameters().getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) { mParams

Flashlight control in Marshmallow

谁都会走 提交于 2019-12-20 18:28:18
问题 I have a problem regarding the camera in the most recent Marshmallow build, more specifically the flashlight. On any pre-Marshmallow version all I need to do to turn the flash on/off was the following: private void turnFlashOn(final Camera camera, int flashLightDurationMs) { if (!isFlashOn()) { final List<String> supportedFlashModes = camera.getParameters().getSupportedFlashModes(); if (supportedFlashModes != null && supportedFlashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) { mParams

Flashlight turns off when other apps are started. Android

会有一股神秘感。 提交于 2019-12-20 03:17:53
问题 I am working on Flashlight app with Widget. When I turn on Flashlight with Widget flashlight is on, and when I start some app, the flashlight turns off. Why is this happening? Why can't my Flashlight run in background? How can I prevent this? I want Flashlight to be turned off only by user not the system. This is my code for widget: @Override public void onReceive(Context context, Intent intent) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout); myPref =

Android How to blink led/flashlight rapidly

寵の児 提交于 2019-12-19 11:27:23
问题 I am trying to give some effects with led/flashlight. but it is not blinking rapidly, even i tried sleep(2), bt it takes time to blink. i want to blink it faster. public void flash_effect() throws InterruptedException { cam = Camera.open(); final Parameters p = cam.getParameters(); p.setFlashMode(Parameters.FLASH_MODE_TORCH); Thread a = new Thread() { public void run() { for(int i =0; i < 10; i++) { cam.setParameters(p); cam.startPreview(); try { Thread.sleep(50); } catch

What method is called after 'applicationDidBecomeActive'?

六月ゝ 毕业季﹏ 提交于 2019-12-19 09:33:13
问题 it's my first question here as I have a problem developing my first iOS app. It is one of the thousands of flashlight apps, however I'm trying to put as many features as possible to it. One of them is saving the state of the app when it goes to background or terminates. After going to foreground (iOS 4 or higher) or relaunching, I'm loading the settings from file and reapplying them. One of the settings is, obviously, the AVCaptureDevice.torchMode . However, I encounter the problem with this.

what is the difference between FLASH_MODE_TORCH AND FLASH_MODE_ON

假装没事ソ 提交于 2019-12-19 04:08:20
问题 My app turn on camera LED using FLASH_MODE_TORCH , but now some people say that FLASH_MODE_TORCH will not work on some Samsung devices correctly. So should I use FLASH_MODE_ON for all devices to work?(especially for Samsung devices) 回答1: may be this will help you Parameters params = null; if(mCamera != null) { params = mCamera.getParameters(); if(params != null) { List<String> supportedFlashModes = params.getSupportedFlashModes(); if(supportedFlashModes != null) { if(supportedFlashModes