I am developing a custom camera app in Android. My goal is to save a picture to file and open it in the fullscreen mode as soon as the file has been saved. Unfortuantely, the problem is that my main activity (ImageCapture) doesn’t wait for ImageCaptureCallback results before calling the next activity (ImageDisplay).
To take a picture I am using a custom ImageCaptureCallback, which saves captured image to “tmpPicturePath” using OutputStream. Later the ImageDisplay activity is called – it reads the file saved in tmpPicturePath.
camera.takePicture(mShutterCallback, mPictureCallbackRaw, new ImageCaptureCallback(this));
// ImageCaptureCallback saves the file in tmpPicturePath
Intent intent = new Intent(ImageCapture.this, ImageDisplay.class);
intent.putExtra("tmpPicturePath", this.getTmpPicturePath());
startActivity(intent);
BUT the file that should be created in ImageCaptureCallback is not yet available at the moment of calling ImageDisplay activity. The overall effect is that not the actual but the previously taken picture is available in the ImageDisplay class. Do you have an idea how to handle this issue? In other words how to wait for callback results before calling the next activity?
Many thanks!
Sample code for taking picture from camera
and in onActivityResult() method