flashlight

app hanging on camera.release()

一世执手 提交于 2019-12-05 20:27:39
I'm working on a flashlight app using the camera flash. It seems to work fine but on occasion calling camera.release() causes a hang for about a minute or so. I've included the code below. I've looked at a bunch of examples and I don't see anything that could cause such a thing. Any ideas? //latest public void setOn(boolean on, Context context) { if (lock) { Log.i(TAG, "lock: true"); return; } if (on) { if (mCamera == null) { mCamera = Camera.open(); } Parameters params = mCamera.getParameters(); params.setFlashMode(MODE_TORCH); mCamera.setParameters(params); mCamera.startPreview(); } else {

Controling Android's front led light

牧云@^-^@ 提交于 2019-12-05 14:45:01
I'm trying to implement a 1 second red blinking at the front led whenever the user presses a certain button. But I'm having trouble finding documentation, tutorials or even code-examples on how to access and work with the front led (by that I mean the led located adjacent to the "selfie" camera and the touch screen). I've seen examples to work with the flashlight and Camera class (deprecated) but I believe that's not what I'm looking for. There is no direct access to the front L.E.D. You can schedule Notifications with custom colours for the L.E.D. Notification.Builder builder = new

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

时光总嘲笑我的痴心妄想 提交于 2019-12-04 11:22:34
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 have added mCamera.startPreview(); because I read that should make a difference, but it doesn't. I also

Flash Torch on Google Nexus 5

假装没事ソ 提交于 2019-12-04 11:09:05
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.setParameters(params); mCamera.startPreview(); try { mCamera.setPreviewTexture(new SurfaceTexture(0)); } catch

Opening flashlight in android with different modes

南笙酒味 提交于 2019-12-04 10:25:29
Will the code as below work on android devices like Motorola razor who doesn't support torch? Can someone please be kind enough to test if has any phone like that and please tell me. Thanks in advance!! if (!isFlashOn) { if (camera == null || params == null) { return; } List<String> flashModes = params.getSupportedFlashModes(); if(flashModes.contains(Parameters.FLASH_MODE_TORCH)){ try { params = camera.getParameters(); params.setFlashMode(Parameters.FLASH_MODE_TORCH); camera.setParameters(params); camera.startPreview(); toggleButtonImage(); isFlashOn = true; }catch (RuntimeException e) { } }

Flashlight control in Marshmallow

≯℡__Kan透↙ 提交于 2019-12-03 05:38:40
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.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); camera.setParameters(mParams); } } } and private void

Flashlight turns off when other apps are started. Android

女生的网名这么多〃 提交于 2019-12-01 22:53:19
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 = PreferenceManager.getDefaultSharedPreferences(context); if (AppGlobals.getIsFlashOn()) { views

Flashlight Camera2 API

為{幸葍}努か 提交于 2019-12-01 12:03:18
Can I use camera preview and flashlight at the same time in Android Camera2 API? When I try use CameraManager.setTorchMode(String cameraId, boolean enabled) it's work fine when camera is not opened. But when Camera is open and I try setTorchMode I receive this exception: CameraService: setTorchMode: torch mode of camera 0 is not available because camera is in use The error is indicating that the camera in question, is already in use. You need to set the FLASH_MODE and CONTROL_AE_MODE accordingly. mPreviewRequestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_OFF);

What method is called after 'applicationDidBecomeActive'?

邮差的信 提交于 2019-12-01 09:16:15
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. I'm reapplying these settings in the applicationDidBecomeActive method. It all seems to work, but when

Flashlight Camera2 API

泪湿孤枕 提交于 2019-12-01 09:06:53
问题 Can I use camera preview and flashlight at the same time in Android Camera2 API? When I try use CameraManager.setTorchMode(String cameraId, boolean enabled) it's work fine when camera is not opened. But when Camera is open and I try setTorchMode I receive this exception: CameraService: setTorchMode: torch mode of camera 0 is not available because camera is in use 回答1: The error is indicating that the camera in question, is already in use. You need to set the FLASH_MODE and CONTROL_AE_MODE