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

  • Home
  • SEARCH
  • 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 3230006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:52:36+00:00 2026-05-17T16:52:36+00:00

I am trying to write an app that requires the LED flash to go

  • 0

I am trying to write an app that requires the LED flash to go into torch mode. The problem is, Android 2.1 does not support this mode and therefore I cannot support the platform yet. Wouldn’t be an issue, but I am writing it for my fiance and her Epic 4G only has 2.1 right now. I found some code samples that use some undocumented API calls and therefore work on the Motorola Droid and such, but they do not work on the Epic. Does anyone have some suggestions on where to look to find code that should help me get this working?

  • 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-17T16:52:37+00:00Added an answer on May 17, 2026 at 4:52 pm

    I’m finding that torch mode is generally working fine on 2.1 but I had the same problem with the Samsung Epic and found a hack around it.

    Looking at the params returned by Camera.getParameters() when run on the Samsung Epic, I noticed that the flash-modes it claims to support are: flash-mode-values=off,on,auto;

    torch-mode is not listed, implying it’s not supported.

    However, I found that this model would still accept that mode and WOULD turn the LED on! The bad news was that when later setting the flash-mode back to auto or off left the LED still lit! It will not turn off until you call Camera.release().

    I guess that’s why Samsung dont include it in the list of supported!?!

    So…the method I use to toggle torch in a CameraHelper class is…

    /***
     * Attempts to set camera flash torch/flashlight mode on/off
     * @param isOn true = on, false = off
     * @return boolean whether or not we were able to set it
     */
    public boolean setFlashlight(boolean isOn)
    {
        if (mCamera == null)
        {
            return false;
        }
        Camera.Parameters params = mCamera.getParameters();
        String value;
        if (isOn) // we are being ask to turn it on
        {
            value = Camera.Parameters.FLASH_MODE_TORCH;
        }
        else  // we are being asked to turn it off
        {
            value =  Camera.Parameters.FLASH_MODE_AUTO;
        }
    
        try{    
            params.setFlashMode(value);
            mCamera.setParameters(params);
    
            String nowMode = mCamera.getParameters().getFlashMode();
    
            if (isOn && nowMode.equals(Camera.Parameters.FLASH_MODE_TORCH))
            {
                return true;
            }
            if (! isOn && nowMode.equals(Camera.Parameters.FLASH_MODE_AUTO))
            {
                return true;
            }
            return false;
        }
        catch (Exception ex)
        {
            MyLog.e(mLOG_TAG, this.getClass().getSimpleName() +  " error setting flash mode to: "+ value + " " + ex.toString());
        }
    }
    

    The activities that use this call it as follows…

    private void toggleFlashLight()
    {
        mIsFlashlightOn = ! mIsFlashlightOn;
    
        /**
         * hack to fix an issue where the Samsung Galaxy will turn torch on,
         * even though it says it doesnt support torch mode,
         * but then will NOT turn it off via this param.
         */
        if (! mIsFlashlightOn && Build.MANUFACTURER.equalsIgnoreCase("Samsung"))
        {
            this.releaseCameraResources();
            this.initCamera();
        }
        else
        {
            boolean result = mCamHelper.setFlashlight(mIsFlashlightOn);
            if (! result)
            {
                alertFlashlightNotSupported();
            }
        }
    }
    

    The magic that makes this work in releaseCameraResources() is that it calls Camera.release()….and then I have to reinitialize all my camera stuff for Samsung devices.

    Not pretty but seems to be working for plenty of users.

    Note that I do have a report of torch mode not working at all with this code on Nexus one but have been able to dig into it. It definitely works on HTC EVO and Samsung Epic.

    Hope this helps.

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

Sidebar

Related Questions

I am trying to write an app that does a person search of my
I am trying to write an android app for root users that runs a
I'm trying to write a small app that monitors how much power is left
I am trying to write a console app that simply lists the number of
I'm trying to write a simple WPF app that has two ellipses, joined by
I'm trying to write an app that can turn my mobile data connection on
I'm a liferay newbie. I'm trying to write a simple php app that echos
I'm trying to support multiple databases for an app that I'm writing. The app
I'm trying to write an app using Ruby on Rails and I'm trying to
I'm trying to write a faster user switching app for Windows. Win+L and selecting

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.