Q: A delay of a Few seconds when trying to power on Led flash Im trying to power on the led flash, but the led flash powers on after a delay of a few seconds. 
I have a built in torch in my phone, and when I click it it the flash turns on immediately.
Whats the problem here?
Heres my code:
private void processOnClick() {

            if (manuName.contains("motorola")) {
                DroidLED led;
                try {
                    led = new DroidLED();
                    led.enable(true);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else {
                if (mCamera == null) {
                    try {
                        mCamera = Camera.open();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                try {
                    mCamera = Camera.open();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                if (mCamera != null) {

                    final Parameters params = mCamera.getParameters();

                    List<String> flashModes = params.getSupportedFlashModes();

                    if (flashModes == null) {
                        return;
                    } else {
                        if (count == 0) {
                            params.setFlashMode(Parameters.FLASH_MODE_OFF);
                            mCamera.setParameters(params);
                            mCamera.startPreview();
                        }

                        String flashMode = params.getFlashMode();

                        if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {

                            if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
                                params.setFlashMode(Parameters.FLASH_MODE_TORCH);
                                mCamera.setParameters(params);
                            } else {
                                // Toast.makeText(this,
                                // "Flash mode (torch) not supported",Toast.LENGTH_LONG).show();

                                params.setFlashMode(Parameters.FLASH_MODE_ON);

                                mCamera.setParameters(params);
                                try {
                                    mCamera.autoFocus(new AutoFocusCallback() {
                                        public void onAutoFocus(boolean success, Camera camera) {
                                            count = 1;
                                        }
                                    });
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }
            }

            if (mCamera == null) {
                return;
            }
        }

     private void processOffClick() {

            if (manuName.contains("motorola")) {
                DroidLED led;
                try {
                    led = new DroidLED();
                    led.enable(false);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else {
                if (mCamera != null) {
                    mCamera.stopPreview();
                    mCamera.release();
                }
            }
        }

DroidLED class:
import java.lang.reflect.Method;

import android.os.IBinder;

class DroidLED {

    private Object svc = null;
    private Method getFlashlightEnabled = null;
    private Method setFlashlightEnabled = null;

    @SuppressWarnings("unchecked")
    public DroidLED() throws Exception {
            try {
                    // call ServiceManager.getService("hardware") to get an IBinder for the service.
                    // this appears to be totally undocumented and not exposed in the SDK whatsoever.
                    Class sm = Class.forName("android.os.ServiceManager");
                    Object hwBinder = sm.getMethod("getService", String.class).invoke(null, "hardware");

                    // get the hardware service stub. this seems to just get us one step closer to the proxy
                    Class hwsstub = Class.forName("android.os.IHardwareService$Stub");
                    Method asInterface = hwsstub.getMethod("asInterface", android.os.IBinder.class);
                    svc = asInterface.invoke(null, (IBinder) hwBinder);

                    // grab the class (android.os.IHardwareService$Stub$Proxy) so we can reflect on its methods
                    Class proxy = svc.getClass();

                    // save methods
                    getFlashlightEnabled = proxy.getMethod("getFlashlightEnabled");
                    setFlashlightEnabled = proxy.getMethod("setFlashlightEnabled", boolean.class);
            }
            catch(Exception e) {
                    throw new Exception("LED could not be initialized");
            }
    }

    public boolean isEnabled() {
            try {
                    return getFlashlightEnabled.invoke(svc).equals(true);
            }
            catch(Exception e) {
                    return false;
            }
    }

    public void enable(boolean tf) {
            try {
                    setFlashlightEnabled.invoke(svc, tf);
            }
            catch(Exception e) {}
    }
}

I took this code from some answer around stackoverflow.
Thanks for your assistance!

A: Do you get high latencies with the motorola?
It's just a guess, but the DroidLED constructor calls expensive system initializations.
Couldn't you do this?
public class MyWidgetClickHandler {
    private DroidLED = null;
    public MyWidgetClickHandler(string ManuName) {
        // This is slow. It will run once at initialization.
        if (ManuName != null && ManuName.toLowerCase().contains("motorola"))
            DroidLED = new DroidLED();
    }

    public void processOnClick() {
        if (DroidLED != null)
            DroidLED.enable(true);
        else
            ; // ... TODO
    }

    public void processOffClick() {
        if (DroidLED != null)
            DroidLED.enable(false);
        else
            ; // ... TODO
    }
}

There could be so much more. For example you could create a LED interface with enable and isEnabled, and have two implementations for it. One would be DroidLED and the other the CommonCameraLED.
With this it looks like this:
public class LEDFactory {
    public static LED createLED(string ManuName) {
        if (ManuName != null && ManuName.toLowerCase().contains("motorola"))
            return new DroidLED();
        else
            return new CommonCameraLED();
    }
}

public class MyWidgetClickHandler {
    private LED myLed = null;
    public MyWidgetClickHandler(string ManuName) {
        myLed = LEDFactory.createLED(ManuName);
    }

    public void processOnClick() {
        myLed.enable(true);
        // NOTHING TO DO
    }

    public void processOffClick() {
        myLed.enable(false);
        // NOTHING TO DO
    }
}

You could also create a Thread for initialization so that phone won't start slow.

A: I just came across the same problem and found a solution, but i made my tests using a Samsung Galaxy S2. This code should work on every device.
Profiling each one of the functions, i found that some calls necessary to setup the camera, sumed up to 500ms in delay, making a strobe effect impossible.
My solution was to move all those functions to a separate function i call when i want to get the camera, and reduce the "turn on" code just to the call to Camera.setParameters(). By doing this, the delay came down to only 4ms. 
For example (reduced code just to to prove the point):
// First get the camera for your app (Keep this variables as class 

members so the live between functions)
private void acquireCamera()
{
    try
    {
        // Get camera
        cam = Camera.open(); 
        // This is not on your code but you should do it for compatibility
        mSurfaceTexture = new SurfaceTexture(0);
        cam.setPreviewTexture(mSurfaceTexture);
        cam.startPreview();
        camParams = cam.getParameters();
    }
    catch(IOException e)
    { /*...*/ }
}

// Then turn on / off as many times you want.
private void setTorch(boolean on)
{
    camParams.setFlashMode(on? Camera.Parameters.FLASH_MODE_TORCH : Camera.Parameters.FLASH_MODE_OFF);
    cam.setParameters(camParams);
}

// Finally release the camera when you`re done
private void releaseCamera
{
    camParams = null;
    cam.stopPreview();
    mSurfaceTexture = null;
    cam.release();
}

