Flash is turning-on fine from application (added surface_view to the layout), when I try to turn-on flash through app-widget it's not working. I used Camera and SurfaceView Here is the code I am using
Camera mCamera;
SurfaceView preview;
mCamera = Camera.open();
mCamera.setPreviewDisplay(preview.getCameraHolder());
Parameters params = mCamera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
mCamera.setParameters(params);
mCamera.startPreview();
Added permission and features in Manifest are:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera.flash" android:required="false" />
The camera needs a surface to cling to in order to open the
Flashlight..however SurfaceView cannot be applied to a widget. So this is what you need to.....
Add this to your
turnFlashOn
code:Also, remove all references to surfaceview in your code as it is not applicable in a widget