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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:17:27+00:00 2026-05-25T06:17:27+00:00

I’m taking a picture using my own camera and trying to save the result

  • 0

I’m taking a picture using my own camera and trying to save the result to the file system (/data/data/package.name/file/captured_photo1.jpeg).
When i try it on the emulator it seems to work – creates a file size 18474 bytes and displays it (i guess this is the emulator’s default photo) .
The problem is that when i try it on my GalaxyS the image on the file system is 0 bytes

the code:

outStream = getApplicationContext().openFileOutput(SolveCaptureActivity.FILE_NAME, Context.MODE_WORLD_READABLE);      
outStream.write(data); //data is of type Byte[]
outStream.flush();
outStream.close();

does anyone have any idea what could it be?

UPDATED:
i found out (from the log) that one of the callbacks i pass to my takePicture method isn’t called. and it’s the one that actually saves it.

the data[] that i get in the rawCallback is null both on the phone and the emulator, but on the emulator the callback is called and it works

this is the whole Activity code:

public class SolveCaptureActivity extends Activity {
      public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.solve_capture);

        preview = new Preview(this);
        ((FrameLayout) findViewById(R.id.preview)).addView(preview);

        buttonClick = (Button) findViewById(R.id.buttonCapture);
        buttonClick.setOnClickListener(new OnClickListener() {
          public void onClick(View v) { 
            preview.camera.takePicture(shutterCallback, rawCallback, jpegCallback);
            Intent gotoImagePreview = new Intent(v.getContext(), CapturedImagePreview.class);
            startActivityForResult(gotoImagePreview, 0);
          }
        });

        buttonFocus = (Button) findViewById(R.id.buttonFocus);
        buttonFocus.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
              preview.camera.autoFocus(new AutoFocusCallback() {
                @Override
                public void onAutoFocus(boolean success, Camera camera) {
                    Camera.Parameters camParam = camera.getParameters();
                    camParam.setFocusMode(Parameters.FOCUS_MODE_AUTO);
                    camera.setParameters(camParam);
                }
              });
            }
        });

        Log.d(TAG, "onCreate'd");
      }

      // Called when shutter is opened
      ShutterCallback shutterCallback = new ShutterCallback() {
        public void onShutter() {
          Log.d(TAG, "onShutter'd");
        }
      };

      PictureCallback rawCallback = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {
          Log.d(TAG, "onPictureTaken - raw");
        }
      };

      PictureCallback jpegCallback = new PictureCallback() { // <8>
        public void onPictureTaken(byte[] data, Camera camera) {
          FileOutputStream outStream = null;
          if (data == null){
              Log.d("@@--DATA--@@, msg","=NULL");
          }
          try {         
            Log.d("@@--DIR--@@", Environment.getExternalStorageDirectory().getAbsolutePath());
            Log.d("@@--Size--@@", Integer.toString(data.length));
            outStream = getApplicationContext().openFileOutput(SolveCaptureActivity.FILE_NAME, Context.MODE_WORLD_READABLE);

            outStream.write(data);
            outStream.flush();
            outStream.close();
            Log.d(TAG, "onPictureTaken - wrote bytes: " + data.length);
          } catch (FileNotFoundException e) { // <10>
            e.printStackTrace();
          } catch (IOException e) {
            e.printStackTrace();
          } finally {
          }
          Log.d(TAG, "onPictureTaken - jpeg");
        }
      };

    }

this is the log:

09-01 18:44:38.403: WARN/CameraService(6488): takePicture (pid 6585)
09-01 18:44:38.403: INFO/ShotSingle(6488): ShotSingle::takePicture start
09-01 18:44:38.403: ERROR/CameraHardwareSec(6488): stopPreview()
09-01 18:44:38.403: ERROR/SecCamera(6488): cancelAutofocus()
09-01 18:44:38.403: ERROR/SecCamera(6488): cancelAutofocus() end, 0, 4
09-01 18:44:38.409: ERROR/SecCamera(6488): stopPreview()
09-01 18:44:38.409: ERROR/SecCamera(6488): fimc_v4l2_streamoff()
09-01 18:44:38.433: ERROR/CameraHardwareSec(6488): stopPreview() end
09-01 18:44:38.433: INFO/ShotSingle(6488): ShotSingle::takePicture end
09-01 18:44:38.433: INFO/ActivityManager(3135): Starting activity: Intent { cmp=cs.workshop.solvedroid/.CapturedImagePreview }
09-01 18:44:38.437: WARN/CameraService(6488): setPreviewCallbackFlag (pid 6585)
09-01 18:44:38.437: DEBUG/Preview(6585): onPreviewFrame called at: 1314891878438
09-01 18:44:38.457: DEBUG/SecCamera(6488): passed fmt = 1498831189 found pixel format[3]: YUV 4:2:2 packed, CbYCrY
09-01 18:44:38.467: WARN/CameraService(6488): width(640), height(480), format:jpeg
09-01 18:44:38.523: WARN/System.err(6585): java.io.FileNotFoundException: /data/data/cs.workshop.solvedroid/files/captured_photo2.jpeg (No such file or directory)
09-01 18:44:38.542: WARN/System.err(6585):     at org.apache.harmony.luni.platform.OSFileSystem.openImpl(Native Method)
09-01 18:44:38.542: WARN/System.err(6585):     at org.apache.harmony.luni.platform.OSFileSystem.open(OSFileSystem.java:152)
09-01 18:44:38.542: WARN/System.err(6585):     at java.io.FileInputStream.<init>(FileInputStream.java:82)
09-01 18:44:38.542: WARN/System.err(6585):     at android.app.ContextImpl.openFileInput(ContextImpl.java:448)
09-01 18:44:38.542: WARN/System.err(6585):     at android.content.ContextWrapper.openFileInput(ContextWrapper.java:152)
09-01 18:44:38.542: WARN/System.err(6585):     at cs.workshop.solvedroid.CapturedImagePreview.onCreate(CapturedImagePreview.java:29)
09-01 18:44:38.542: WARN/System.err(6585):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-01 18:44:38.543: WARN/System.err(6585):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
09-01 18:44:38.543: WARN/System.err(6585):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
09-01 18:44:38.545: WARN/System.err(6585):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
09-01 18:44:38.545: WARN/System.err(6585):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
09-01 18:44:38.547: WARN/System.err(6585):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-01 18:44:38.547: WARN/System.err(6585):     at android.os.Looper.loop(Looper.java:123)
09-01 18:44:38.549: WARN/System.err(6585):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-01 18:44:38.549: WARN/System.err(6585):     at java.lang.reflect.Method.invokeNative(Native Method)
09-01 18:44:38.551: WARN/System.err(6585):     at java.lang.reflect.Method.invoke(Method.java:521)
09-01 18:44:38.553: WARN/System.err(6585):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-01 18:44:38.553: WARN/System.err(6585):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-01 18:44:38.555: WARN/System.err(6585):     at dalvik.system.NativeStart.main(Native Method)
09-01 18:44:38.643: WARN/CameraService(6488): stopPreview (pid 6585)
09-01 18:44:38.643: ERROR/CameraHardwareSec(6488): stopPreview()
09-01 18:44:38.643: ERROR/SecCamera(6488): cancelAutofocus()
09-01 18:44:38.643: ERROR/SecCamera(6488): cancelAutofocus() end, 0, 4
09-01 18:44:38.643: ERROR/SecCamera(6488): stopPreview()
09-01 18:44:38.645: ERROR/SecCamera(6488): stopPreview: m_flag_camera_start is zero
09-01 18:44:38.645: ERROR/CameraHardwareSec(6488): stopPreview() end
09-01 18:44:38.645: WARN/CameraService(6488): stopPreview(), hardware stopped OK
  • 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-25T06:17:27+00:00Added an answer on May 25, 2026 at 6:17 am

    fixed (with the gracious help of Pixie )

    the callback wasn’t called because i had to use

    Intent gotoImagePreview = new Intent(v.getContext(), CapturedImagePreview.class);
    startActivityForResult(gotoImagePreview, 0);
    

    at the end of my PictureCallback jpegCallback = new PictureCallback() callback so it’ll store the image on the file system first because otherwise it calls startActivityForResult before it makes it to the last callback.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I am trying to render a haml file in a javascript response like so:
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the

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.