I am implementing strobe functionality which works fine ( the LED camera flash light turn on/off) the problem that i occurring is that the turn on/off with different frequency in different devices. In HTC SensationXE its blinking fast and in NEXUS its blinking slow dont know what the issue is. Can anyone help please: Here is code:
/*
* This method turn on the LED camera flash light
*/
public void flashLightOn() {
Log.d("Time", "On");
if (!isFlashOn) {
if (cam != null || params != null) {
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(params);
cam.startPreview();
isFlashOn = true;
} else {
cam = Camera.open();
params = cam.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(params);
cam.startPreview();
isFlashOn = true;
}
}
else{
return;
}
}
/*
* This method turn off the LED camera flash light
*/
public void flashLightOff() {
Log.d("Time", "Off");
if (isFlashOn) {
if (cam != null || params != null) {
//params.setFlashMode(Parameters.FLASH_MODE_OFF);
//cam.setParameters(params);
cam.stopPreview();
isFlashOn = false;
}
else{
//params = cam.getParameters();
//params.setFlashMode(Parameters.FLASH_MODE_OFF);
//cam.setParameters(params);
cam.stopPreview();
isFlashOn = false;
}
}
else{
return;
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
// TODO Auto-generated method stub
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
mHolder = holder;
try {
cam.setPreviewDisplay(mHolder);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
// TODO Auto-generated method stub
cam.stopPreview();
mHolder = null;
}
private final Runnable mRunnable = new Runnable() {
public void run() {
if (mActive) {
if (mSwap) {
flashLightOn();
mSwap = false;
mHander.postDelayed(mRunnable, strobeOnDelay);
} else {
flashLightOff();
mSwap = true;
mHander.postDelayed(mRunnable, strobeOffDelay);
}
}
}
};
My class is implemention SurfaceHolder.Callback