I saw that there are many questions liek this but I didn't find any way. In my app I have my own Camera with some options , and also have button named btnFlash
for turning on/off camera's flash light while camera is running. I tried many ways, but nothing worked as on Samsung tab and HTC. here is one of them
ImageButton btnFlash = (ImageButton) findViewById(R.id.btn_flash);
btnFlash.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Context context = getApplicationContext();
if( context .getPackageManager().hasSystemFeature(getPackageManager().FEATURE_CAMERA_FLASH)) {
Parameters params = mCamera.getParameters();
if(isFlashOn) {
params.setFlashMode(Parameters.FLASH_MODE_OFF);
mCamera.setParameters(params);
isFlashOn = false;
} else {
params.setFlashMode(Parameters.FLASH_MODE_ON);
mCamera.setParameters(params);
isFlashOn = true;
}
}
}
});
- Can anyone suggest some good tutorial or some code?
- Can same code work on e.g. HTC but not work on samsung? I mean can I wrote some code for any type of android device?
Thanks in advance..