Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, this was an improvement of the 2.3. </p> <p>I had this problem in 2.2 as well, there was no way to work on a preview image despite the fact this was theoretically possible according to the API. To solve this I had to actually take a picture using <code>Camera.takePicture(null, null, Camera.PictureCallback myCallback)</code> (see info <a href="http://file:///D:/android/android/android-sdk-windows/docs/reference/android/hardware/Camera.html#takePicture%28android.hardware.Camera.ShutterCallback,%20android.hardware.Camera.PictureCallback,%20android.hardware.Camera.PictureCallback,%20android.hardware.Camera.PictureCallback%29" rel="nofollow">here</a>) and then to implement a callback to handle the taken picture. The instance of the class that implements this callback is actually the parameter to pass to <code>Camera.takePicture()</code> and the callback method itself looks like this:</p> <pre><code>public void onPictureTaken(byte[] JPEGData, Camera camera) { final Bitmap bitmap = createBitmapFromView(JPEGData); // do something with the Bitmap } </code></pre> <p>Doing that way prevents the picture to be saved on the external storage with the regular pictures taken with the camera application. Should you need to serialize the <code>Bitmap</code> you'll have to do it explicitely. But it doesn't prevent the camera's trigger sound from being emitted.</p> <p><code>Camera.takePicture()</code> has to be called wile the preview is running. <code>stopPreview()</code> can be called right after.</p> <p><strong>One thing to be careful with /!\:</strong></p> <p><code>Camera.takePicture()</code> is not reentrant (at all). The callback must have returned before any subsequent call of <code>Camera.takePicture()</code>. This was freezing my phone, I had to shutdown and restart it before it to be usable again. As the action was triggered by a button, on my side, I had to shield it with a boolean:</p> <pre><code>if (!mPictureTaken) { mPictureTaken = true; // absolutely NOT reentrant. Any double click sticks the phone otherwise. mCameraView.takePicture(callback); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload