Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4252944
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T04:52:55+00:00 2026-05-21T04:52:55+00:00

I’m trying to use the cameras LED flashlight in a widget. I’ve found several

  • 0

I’m trying to use the cameras LED flashlight in a widget. I’ve found several threads about this topic (i.e. the one mentioned later..) , now I’m trying to control the light using:

Camera cam = Camera.open();     
Parameters p = cam.getParameters();
p.setFlashMode(Parameters.FLASH_MODE_TORCH);
cam.setParameters(p);
cam.release();

In the AndroidManifest.xml tried different permissions, currently I have:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT"/>
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.flash" />

I’m testing this on my Galaxy Tab as I don’t have any other Android devices at hand: the light does not turn on. So I have a few questions now:

  1. Is there any way to test the led light behavior in the Emulator?
  2. Am I doing something wrong here?
  3. According to this question which deals with the same problem, it works differently on the Galaxy Tab. How?
  4. And finally, if it does work differently, I’m starting to wonder if it’s just the Galaxy Tab or if other devices use different methods too. It would be hard to test then and it seems rather odd to me.

Thanks for any insight!

By the way, I quickly tested with quick-settings which gets mentioned a few times here. The flashlight doesn’t work with quick-settings either.

Note that the Galaxy Tab stil uses android 2.2. I see there were some changes between 2.2 and 2.3.

Comment:
I know it has to work somehow as I have found other apps in the market that work perfectly with the Galaxy Tab.

Comment 2:
If I set cam.setParameters(p); and directly ask the camera for the current state with getFlashMode() it correctly returns FLASH_MODE_TORCH. However, if I release the camera and re-open it, it returns FLASH_MODE_OFF. It’s almost as if the Camera object aknowledges the request but doesn’t really pass it on to the hardware!?

—

After Konstantins comment, I removed the cam.release(); part. He is right, the settings are not persisted if you release the camera. If you use cam.open() again, you will get a fresh instance with the light off. The light’s still not working on the galaxy tab though.
So, I guess it’s hard to keep the light on if you’re trying to control it through a widget then. As soon as the background service is finished, the camera object is released automatically and therefore the light switches off again. My questions still remain, especially why the camera doesn’t switch on in the first place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T04:52:56+00:00Added an answer on May 21, 2026 at 4:52 am

    Every device is a bit different. Samsung especially likes to make things complicated for app developers.

    On the Galaxy Tab you should be good with:

    Camera cam;
    void ledon() {
        cam = Camera.open();     
        Parameters params = cam.getParameters();
        params.setFlashMode(Parameters.FLASH_MODE_ON);
        cam.setParameters(params);
        cam.startPreview();
        cam.autoFocus(new AutoFocusCallback() {
                    public void onAutoFocus(boolean success, Camera camera) {
                    }
                });
    }
    
    void ledoff() {
        cam.stopPreview();
        cam.release();
    }
    

    If that doesn’t work then it might be a matter of setting FLASH_MODE_OFF initially and changing it after the startPreview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.