Is your activity implementing the Camera.PreviewCallback? As for the
file writing stuff I agree that is a pretty intense thing to do
several times a second, you might want to reconsider that or create a
Thread that does the writing.

On Jul 26, 12:01 pm, TurboMan <[email protected]> wrote:
> Hi,
>
> I have an application which uses Camera preview feature.
> I can see the camera preview without any problem.
> But, OOH I need to capture preview frame.
> I've googled and find out the setPreviewCallback.
> But my tablet PC doesn't callback this function as follows.
> I am not sure if I am doing something wrong.
> Any help is appreciated.
>
> In SurfaceHolder.Callback class in surfaceCreated function I have the
> following code.
> [Code]
>         mCamera = Camera.open();
>         try {
>           mCamera.setPreviewCallback(new PreviewCallback() {
>             @Override
>             public void onPreviewFrame(byte[] data, Camera arg1) {
>                 FileOutputStream outStream = null;
>                 try {
>                     outStream = new FileOutputStream(String.format(
>                             "/sdcard/%d.jpg", System.currentTimeMillis()));
>                     outStream.write(data);
>                     outStream.close();
>                     Log.d(TAG, "onPreviewFrame - wrote bytes: "
>                             + data.length);
>                 } catch (FileNotFoundException e) {
>                     e.printStackTrace();
>                 } catch (IOException e) {
>                     e.printStackTrace();
>                 } finally {
>                 }
>                 Preview.this.invalidate();                
>             }
>            });
>            mCamera.setPreviewDisplay(holder);
>         } catch (IOException exception) {
>         //} finally {
>             mCamera.release();
>             mCamera = null;
>         }
>  [/Code]

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to