1

I am trying to add the ability to turn on the LED flash within my app. It's not the app's primary function so I am not trying to capture every single device.

I have added the following code:

    flash_ok = getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH);

    if(flash_ok){
        torch_image.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if(mCamera == null){
                   try{
                         mCamera = Camera.open();
                 }catch ( Exception e ){

                }
                if(!torch_is_on){
                    processOnClick();
                }
                else(torch_is_on){
                    processOffClick();
                }
            }
        });
    }

This works just fine on every device I have tested so far (light doesn't light on the original Galaxy Tab but that's not an issue) but causes a force close on the Xoom. I don't have the device in my possession so I can't debug.

Any ideas?

Thanks

EDIT: Okay I have tried the same app on another Xoom and not only did it not crash but the light lit! My only guess is there a problem with the other device's hardware.

Leon
  • 3,614
  • 1
  • 33
  • 46
  • My experience is that camera access is a pain on Android. Neither Google (with the insufficiently documented camera API) nor the device manufacturers seem to spend a lot of effort on designing, implementing and testing cameras that work reliably and the same on all devices. – Codo Nov 17 '11 at 13:10
  • one thing that might be happening is that you're setting a flash move that isn't in Camera.Parameters.getSupportedFlashModes(). I haven't had this cause crashes for me, but it's probably worth checking. – Chris Bye Nov 17 '11 at 13:18
  • Slothsberry, I have a try-catch statement in my OnClick method also so this should be caught surely? Thanks – Leon Nov 18 '11 at 16:44
  • I'm the developer of Flashlight + Led and can anyone test the app https://market.android.com/details?id=droid.pr.coolflashlightfree to see if works with xoom? I want to add support for it but I don't have the device – Pedro Rainho Mar 01 '12 at 14:02

0 Answers0