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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:11:09+00:00 2026-06-09T17:11:09+00:00

I have an app where I open the camera at onResume() method: @Override public

  • 0

I have an app where I open the camera at onResume() method:

@Override
    public void onResume() {
            super.onResume();
        openCamera();
        ....
}


public void openCamera() {
        try {
            camera = Camera.open();
            Log.d(CAMERA, "Camre opened");
        } catch (Exception exception) {
            Log.e(CAMERA, "Cannot open camera", exception);
        }
    }

openCamera() method works fine if I don’t call it in onResume() method, but within onResume() method it gives me the following exception:

08-15 14:50:33.999: E/camera(1753): Cannot open camera
08-15 14:50:33.999: E/camera(1753): java.lang.RuntimeException: Fail to connect to camera service
08-15 14:50:33.999: E/camera(1753):     at android.hardware.Camera.native_setup(Native Method)
08-15 14:50:33.999: E/camera(1753):     at android.hardware.Camera.<init>(Camera.java:302)
08-15 14:50:33.999: E/camera(1753):     at android.hardware.Camera.open(Camera.java:279)
08-15 14:50:33.999: E/camera(1753):     at buet.threebyzero.autoSecuritySystem.Capture.openCamera(Capture.java:46)
08-15 14:50:33.999: E/camera(1753):     at buet.threebyzero.autoSecuritySystem.Capture.onResume(Capture.java:55)
08-15 14:50:33.999: E/camera(1753):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
08-15 14:50:33.999: E/camera(1753):     at android.app.Activity.performResume(Activity.java:4539)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-15 14:50:33.999: E/camera(1753):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-15 14:50:33.999: E/camera(1753):     at android.os.Looper.loop(Looper.java:137)
08-15 14:50:33.999: E/camera(1753):     at android.app.ActivityThread.main(ActivityThread.java:4424)
08-15 14:50:33.999: E/camera(1753):     at java.lang.reflect.Method.invokeNative(Native Method)
08-15 14:50:33.999: E/camera(1753):     at java.lang.reflect.Method.invoke(Method.java:511)
08-15 14:50:33.999: E/camera(1753):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-15 14:50:33.999: E/camera(1753):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-15 14:50:33.999: E/camera(1753):     at dalvik.system.NativeStart.main(Native Method)

EDIT: Problem partially solved after restarting the emulator and overriding onPause() method:

@Override
    protected void onPause() {
        super.onPause();
        if(camera != null)
            camera.release();
    }
  • 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-09T17:11:11+00:00Added an answer on June 9, 2026 at 5:11 pm

    Not sure if this is the problem, but make sure you release the camera everytime when your Activity goes in background.

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

Sidebar

Related Questions

I am making the qr-code reader app,on button click i have opened the camera
I would like to have my app open the camera (presently UIImagePickerController ) front-facing
In my IOS app, when I open the camera I have placed an image
I have an app that can open up some other forms at the user's
If I have several OS-X Terminal.app windows open, how can I move one Terminal
I have client/server application where the client app will open files. Those files get
I have an open-source app which uploads photos to Facebook. To save bandwidth, the
I have an WinMo app and I would like to open a file from
How do I open SMS from my app and have the new message popped
I have an HTML file which is launching an app if I open it

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.