Please help me to understand where is exact problem.
I download from google play store and thats woreking very fine but when I Run from my code led flashlight is not working.
Blockquote
My Code is:
Camera camera = null;
Parameters parameters;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Button FlashLightControl = (Button)findViewById(R.id.flashcontrol);
FlashLightControl.setText("Set FLASH_MODE_TORCH");
FlashLightControl.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View arg0) {
if(camera == null){
camera = Camera.open();
parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
FlashLightControl.setText("Set FLASH_MODE_OFF");
}else{
parameters = camera.getParameters();
parameters.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.release();
camera = null;
FlashLightControl.setText("Set FLASH_MODE_TORCH");
}
}});
and Manifest:
<uses-feature android:name="android.hardware.camera" />
<!-- Camera Permissions -->
<!-- Features -->
<uses-feature android:name="android.hardware.camera.flash" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA"/>