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 8462693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:14:17+00:00 2026-06-10T14:14:17+00:00

I followed the tutorial here and managed to implement the flash light into my

  • 0

I followed the tutorial here and managed to implement the flash light into my app. However I have come unstuck.

The flash light button works wonders upon first load of the app, but when you go to another activity (page) and then come back to the first activity (page) and try to use the flash light button it force closes the app

Here is the logCat I loaded the app, turned torch on and off navigated to another activity and back then tried the flash light again and bam dead

08-18 23:12:50.854: I/info(10685): torch is turn on!
08-18 23:12:51.565: D/View(10685): onTouchEvent: viewFlags: 0x18004001
08-18 23:12:51.565: D/View(10685): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
08-18 23:12:51.565: I/info(10685): torch is turn off!
08-18 23:12:58.522: D/View(10685): onTouchEvent: viewFlags: 0x18004001
08-18 23:12:58.522: D/View(10685): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
08-18 23:12:58.672: D/ATRecorder(10685): com.htc.autotest.dlib.RecordEngine in loader dalvik.system.DexClassLoader@4054f238
08-18 23:12:58.682: D/WindowManagerImpl(10685): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40545f00
08-18 23:12:58.912: D/Camera-JNI(10685): native_release: context=0x34cec0 camera=0x34ce78
08-18 23:13:00.844: W/KeyCharacterMap(10685): Can't open keycharmap file
08-18 23:13:00.854: W/KeyCharacterMap(10685): Error loading keycharmap file '/system/usr/keychars/synaptics-rmi-touchscreen.kcm.bin'. hw.keyboards.65537.devname='synaptics-rmi-touchscreen'
08-18 23:13:00.854: I/KeyCharacterMap(10685): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
08-18 23:13:01.214: D/WindowManagerImpl(10685): finishRemoveViewLocked, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40545f00
08-18 23:13:02.205: D/View(10685): onTouchEvent: viewFlags: 0x18004001
08-18 23:13:02.205: D/View(10685): onTouchEvent: isFocusable: true, isFocusableInTouchMode: false, isFocused: false; focusTaken: false
08-18 23:13:02.205: I/info(10685): torch is turn on!
08-18 23:13:02.205: D/AndroidRuntime(10685): Shutting down VM
08-18 23:13:02.205: W/dalvikvm(10685): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
08-18 23:13:02.215: E/AndroidRuntime(10685): FATAL EXCEPTION: main
08-18 23:13:02.215: E/AndroidRuntime(10685): java.lang.RuntimeException: Method called after release()
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.hardware.Camera.native_setParameters(Native Method)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.hardware.Camera.setParameters(Camera.java:958)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at com.reading.festival.ReadingFestivalGuide2012Activity$1.onClick(ReadingFestivalGuide2012Activity.java:84)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.view.View.performClick(View.java:2533)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.view.View$PerformClick.run(View.java:9320)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.os.Handler.handleCallback(Handler.java:587)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.os.Handler.dispatchMessage(Handler.java:92)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.os.Looper.loop(Looper.java:150)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at android.app.ActivityThread.main(ActivityThread.java:4385)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at java.lang.reflect.Method.invokeNative(Native Method)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at java.lang.reflect.Method.invoke(Method.java:507)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
08-18 23:13:02.215: E/AndroidRuntime(10685):    at dalvik.system.NativeStart.main(Native Method)

code used for camera

private boolean isLighOn = false;

    private Camera camera;

    private Button button;

    @Override
    protected void onStop() {
        super.onStop();

        if (camera != null) {
            camera.release();
        }
    }


        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //makes full screen and takes away title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        //



        setContentView(R.layout.main);

        button = (Button) findViewById(R.id.buttonFlashlight);

        Context context = this;
        PackageManager pm = context.getPackageManager();

        // if device support camera?
        if (!pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            Log.e("err", "Device has no camera!");
            return;
        }

        camera = Camera.open();
        final Parameters p = camera.getParameters();

        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (isLighOn) {

                    Log.i("info", "torch is turn off!");

                    p.setFlashMode(Parameters.FLASH_MODE_OFF);
                    camera.setParameters(p);
                    camera.stopPreview();
                    isLighOn = false;

                } else {

                    Log.i("info", "torch is turn on!");

                    p.setFlashMode(Parameters.FLASH_MODE_TORCH);

                    camera.setParameters(p);
                    camera.startPreview();
                    isLighOn = true;

                }

            }
        });
  • 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-06-10T14:14:18+00:00Added an answer on June 10, 2026 at 2:14 pm

    You have called camera.setparameters() after calling camera.release().
    You should not call setparameters after releasing it.

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

Sidebar

Related Questions

I have followed this tutorial here as mentioned exactly I now try to run
I followed this tutorial to implement facebook into my application. All I want is
I've followed the tutorial here: http://book.cakephp.org/view/1286/Sending-a-basic-message , which I have successfully used before with
I have followed the tutorial here http://projectlombok.org/ but after adding import and @Data nothing
I've followed the tutorial here to load video files into a C program. But
I followed this tutorial here: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/ It works great but when I enable CSRF
I followed the tutorial found here and added my own flare to it: tutorial
So here's my issue: I followed the NSURLConnection tutorial in the iPhone Developer Documentation
Beginner here to hibernate, spring. Followed tutorial here to setup hibernae + spring +
I followed the tutorial here but when I create the project in Eclipse, i

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.