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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:53:27+00:00 2026-06-06T11:53:27+00:00

I have an app in which the client uses the camera to take a

  • 0

I have an app in which the client uses the camera to take a picture. The preview of the image is being shown in the tablet using a SurfaceView, before the person hits my “click” button. When the person hits the click button, the method onPictureTaken is called, and, in that method, I save the image and also call the camera.stopPreview() method (so the user can see the picture that was taken).

There is an issue, however… If the user is moving around the tablet at the moment that the picture is taken, the still picture actually shown after the stopPreview method is called DOES NOT correspond to the one that I get in the byte array of the onPictureTaken method. There is a delay of some miliseconds there in which make that difference to stand out when the user is moving around the tablet just before the picture is taken (I know that 99% of the people will not move the tablet around while taken the picture, but my client actually noticed this issue and want it fixed…). I have tried to move the save operation to a separete thread, as shown below, so the onPictureTaken method can execute as fast as possible. Still, it had no effect at all…

private PictureCallback pictureCallback = new PictureCallback() {

    public void onPictureTaken(byte[] data, Camera camera) {

        camera.stopPreview();
        reference = data;

        new PictureCallbackHeavy().execute();
    }
};

I have also trield to call camera.stopPreview() just BEFORE I call the takePicture method (and not inside the onPictureTaken() method). But the result is the same.

What can I do to sync the stopPreview method so I can show EXACTLY the image that was taken and that is in the byte array of the onPictureTaken() callback?

Thank you in advance!! =)

  • 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-06T11:53:29+00:00Added an answer on June 6, 2026 at 11:53 am

    Unfortunately you can’t acquire a reasonable good preview image just by calling stopPreview() because between the moment the picture is taken and the moment onPictureTaken() is called there can pass quite some time because it works like this:

    • The camera actually takes the picture (that’s what you want to preview)
    • onShutter() is called
    • onPictureTaken() for the raw image data is called (on some devices)
    • onPictureTaken() for a scaled preview image is called (on some devices)
    • onPictureTaken() for the final compressed image data is called (the one we are talking about here)

    So you have to convert the byte[] data in your onPictureTaken() callback into a Bitmap and map that Bitmap onto an ImageView that you should position above your SurfaceView to show the still preview image.
    The code will probably look something like this:

    public void onPictureTaken(byte[] data, Camera camera) {
        camera.stopPreview();
        final Bitmap image = BitmapFactory.decodeByteArray(data, 0, data.length);
        surfaceView.setVisibility(SurfaceView.GONE);
        imageView.setVisibility(ImageView.VISIBLE);
        imageView.setImageBitmap(image);
        reference = data;
        new PictureCallbackHeavy().execute();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an android app which uses camera. I am using a socket connection
I have an ASP.NET MVC server app and client code which uses jquery. I'd
I have a simple ASP.NET web app which uses a WCF Client to talk
We have client server based app which saves user related data into a zip
I have an app which uses a keyboard hook procedure in a library. The
I'm implementing a web app, which uses sessions. I'm using GWT and app engine
I have an app which, long story short, uses the clipboard for part of
I have started creating an app which uses a core data stack at the
I have an Android app which uses Jackson parser for JSON parsing. After I've
I have a Java game that uses networking, and I have a client (using

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.