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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:34:32+00:00 2026-05-22T23:34:32+00:00

I am writing an application that needs pictures taken with the camera. The problem

  • 0

I am writing an application that needs pictures taken with the camera. The problem occurs when I try to take an actual picture. Here’s the code that is troubling me:

    final ShutterCallback shutterCallback = new ShutterCallback() {
        @Override
        public void onShutter() {
            Log.d(TAG, "onShutter");
        }
    };

    final PictureCallback callback = new PictureCallback() {

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {
            Log.d(TAG, "onPictureTaken - jpeg");
            try {
                //async task for storing the photo
                new SavePhotoTask(CameraView.this.ctx, data).execute();
            } catch (final SavePhotoException e) {
                //some exceptionhandling
            }
        }
    };
    this.camera = Camera.open();
    this.camera.setPreviewDisplay(surfaceHolder);
    final Camera.Parameters parameters = findBestParameters(w, h);
    this.camera.setParameters(parameters);
    this.camera.startPreview();
    Log.d(TAG, "takePicture now!");
    this.camera.takePicture(shutterCallback, null, callback);

On the emulator it seems to work out but on my phone (Motorola Defy – android 2.1).

The actual problem: on the phone the picturecallback is never happening “onPictureTaken” gets never called. The Shuttercallback is executed but the other is not (and I tried with raw instead of jpeg, same thing).

Does anyone know this problem? I just don’t see where the difference lies to the emulator right now. I appreciate your help.

  • 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-22T23:34:33+00:00Added an answer on May 22, 2026 at 11:34 pm

    I finally went and debugged the problem. All of a sudden it worked, because debugging is much slower: It’s a timing problem. The callback takes some time to be called. While debugging the phone had enough time to finish taking the picture …

    Also don’t go calling Camera.stopPreview() and Camera.release() too early.

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

Sidebar

Related Questions

I'm writing an application that needs to verify HMAC-SHA256 checksums. The code I currently
I am writing an application that needs to bring window of an external app
I am writing an application that needs to send data over a network. I
I'm writing an application that needs a log-like view, (similar to how an IM
So, I'm writing a Cocoa application that needs to be able to display web
I am writing an application in C# that needs to run as a service
I'm writing a query for an application that needs to list all the products
im writing an application that downloads and installs addons for programs which needs to
I am writing a web application that works with exchange, and so needs to
I am currently writing an application that needs to pull data from an XHTML

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.