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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:34:18+00:00 2026-06-04T00:34:18+00:00

Probably 90% of the time, the callbacks will fail to trigger. And hence my

  • 0

Probably 90% of the time, the callbacks will fail to trigger.
And hence my picture is never saved.

What am I doing wrong?

   @Override
public boolean onTouchEvent(MotionEvent event)
{
    boolean result = super.onTouchEvent(event);

       int action = event.getAction();
       if(action == MotionEvent.ACTION_DOWN)
       {
           takePicture();

           this.finish(); // ERROR IS HERE. Closing down before callback is done.

       }    
       return result;
}

private void takePicture() {
    if (mCamera != null)
        mCamera.takePicture(shutterCallback, null, jpegCallback);     
}

ShutterCallback shutterCallback = new ShutterCallback() {
      public void onShutter() {

          AudioManager meng = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
            int volume = meng.getStreamVolume( AudioManager.STREAM_NOTIFICATION);

            if (volume != 0)
            {
                    MediaPlayer _shootMP = MediaPlayer.create(getBaseContext(), Uri.parse("file:///system/media/audio/ui/camera_click.ogg"));
                    _shootMP.start();
            }
      Toast.makeText(CameraActivity.this, "Picture Taken", Toast.LENGTH_SHORT).show();
      }
};

PictureCallback rawCallback = new PictureCallback() {
      public void onPictureTaken(byte[] _data, Camera _camera) {
        // TODO Do something with the image RAW data.
          int test = 1;
      }
};

PictureCallback jpegCallback = new PictureCallback() {
  public void onPictureTaken(byte[] _data, Camera _camera) {
      File photo=new File(Environment.getExternalStorageDirectory(), "photo1.jpg");

      if (photo.exists()) {
            photo.delete();
      }

      try {
        FileOutputStream fos=new FileOutputStream(photo.getPath());

        fos.write(_data);
        fos.close();
      }
      catch (java.io.IOException e) {
        Log.e("PictureDemo", "Exception in photoCallback", e);
      }



      SqlDB.SavePhoto(1, _data);      
  }
};
  • 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-04T00:34:20+00:00Added an answer on June 4, 2026 at 12:34 am

    Can you debug and check is it going in any of the function rawCallback or jpegCallback. You are setting jpeg format for your camera or not. I think according to that callback function will be called. So it should either go in rawCallback or jpegCallback. Can you try once.

    mCamera.takePicture(shutterCallback, rawCallback , jpegCallback);

    if it is failing then where it is going may be somewhere you are opening your camera again. In this case i think your camera parameter will be reset and may return raw callback instead of jpeg

    Actually I think if camera is not crashing and it is not null then is the only case remains is you are resetting your camera with default settings or you are opening your camera again..

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

Sidebar

Related Questions

It's probably the tenth time I'm implementing something like this, and I've never been
I'm probably over-thinking this/wasting time trying to avoid a bit of conditional code -
i've spent some time searching and there is probably is an easy way to
Probably I cant get more dumb, but seriously this is the first time I
I know this is probably super easy, but I'm having a hard time wading
I need to know how to read Javadoc comments at run-time (probably by reflection?)
probably I'm sinking in an empty glass or maybe i've spent too many hours
Probably something really simple, but I'm having some real trouble with it. I have
Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
Probably I'm just too dump for googling, but I always thought char arrays get

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.