Forward Facing Camera

by paul zazzarino » Sun, 08 Nov 2009 22:39:59 GMT


Sponsored Links
 Anyone have any knowledge of Android devices with forward facing cameras which 
are programable ?
[Native code is ok, does not have to be Java]


--



Other Threads

1. Is it possible to add my app to the Picture Options list(Menu) of the Gallery app.

Hi there, i am new to android and java, and i have searched the web
now for 2 days for a anzswer to my question.

I would like to write a app (activity) to edit a picture from the
gallery, like the rotate and corp functions.
I would like to find a way to add my app to the menu what pops up
(Picture options) when you press and hold
a selected picture or when you press the menu button.

I have read some where that this ois some how posible with
intentfilter in the AndroidManifest.xml

If some one has a clou how this works and maybe has a sample code to
follow would be great.

Best regards
AnubisAndroid

--~--~---------~--~----~------------~-------~--~----~

2. In my app.ShutterCallback didn't implemented

public class Preview extends SurfaceView implements
SurfaceHolder.Callback {
        SurfaceHolder mHolder;
        Camera mCamera;

        Preview(Context context) {
                super(context);
                mHolder = getHolder();
                mHolder.addCallback(this);
                mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }

            public void surfaceCreated(SurfaceHolder holder) {
                                mCamera = Camera.open();
                Camera.Parameters parameters=mCamera.getParameters();
           parameters.setPictureFormat(PixelFormat.JPEG);
            parameters.setPictureSize(420, 320);
                mCamera.setParameters(parameters);

                mCamera.setPreviewCallback(previewCallback);
                 mCamera.takePicture(shutterCallback, pictureCallback,
                  jpegPictureCallback);
                try {
                        mCamera.setPreviewDisplay(holder);
                } catch (IOException e) {

                        e.printStackTrace();
                }
        }


        private PreviewCallback previewCallback = new PreviewCallback() {

                @Override
                public void onPreviewFrame(byte[] data, Camera camera) {

                        Log.i("Preview", "onPreviewFrame");
                }

        };

        int i = 0;
        private ShutterCallback shutterCallback = new ShutterCallback() {

                @Override
                public void onShutter() {

                        Log.i("Preview", "onShutter");
                        if (++i > 1) {
                                mCamera.stopPreview();
                        }
                }

        };

        private PictureCallback pictureCallback = new PictureCallback() {

                @Override
                public void onPictureTaken(byte[] data, Camera camera) {

                        Log.i("Preview", "onPictureTaken");
                }

        };

        private byte[] picData;
        private PictureCallback jpegPictureCallback = new PictureCallback() {

                @Override
                public void onPictureTaken(byte[] data, Camera camera) {

                        picData = data;
                        Log.i("Preview", "onPictureTaken jpeg");
                }

        };

        public String getPicture() throws IOException {
                //mCamera.takePicture(shutterCallback,pictureCallback,
jpegPictureCallback);
                mCamera.takePicture(shutterCallback, pictureCallback,
                                jpegPictureCallback);
                if (picData == null) {
                        return null;
                }
                int bytelength=picData.length;
                int length=1024;
                 String dataString = new SimpleDateFormat("yyyy-mm-dd
HH:mm:ss").format(Calendar.getInstance().getTime());
                 dataString=dataString.replaceAll("\\s", "");
                 dataString=dataString.replaceAll(":", "");

                    String pathString="/sdcard/"+dataString+".jpg";

                FileOutputStream fos = null;
                        try {
                                  fos=new FileOutputStream(pathString);
                                   int offset=0;
                                  while(offset+length<bytelength){
                                          fos.write(picData, offset, length);
                                          offset+=length;
                                  }
                                  fos.write(picData, offset, bytelength-offset);

                        } catch (Exception e) {
                                 Log.e("ww",e.toString());
                        }finally{
                                        fos.close();
                        }



                return pathString;
        }

        public void cancel() {
                mCamera.stopPreview();
                mCamera.release();
                mCamera = null;
        }

        public void surfaceDestroyed(SurfaceHolder holder) {
                // Surface will be destroyed when we return, so stop the
                // preview.
                // Because the CameraDevice object is not a shared resource,
                // it's very
                // important to release it when the activity is paused.
                if (mCamera != null) {
                        mCamera.stopPreview();
                        mCamera = null;
                }
        }

        public void surfaceChanged(SurfaceHolder holder, int format, int w,
int h) {
                // Now that the size is known, set up the camera parameters
                // and begin
                // the preview.
                Camera.Parameters parameters = mCamera.getParameters();
                parameters.setPreviewSize(w, h);
                mCamera.setParameters(parameters);
                mCamera.startPreview();
        }

}


And when  toggle a breakpoint in the private ShutterCallback
shutterCallback = new ShutterCallback(),it hasn't been implemented.
So when I invoke the getPicture outside ,the picture is black and the
pisdata is null.
Why this happen?Where did i do wrong?

--~--~---------~--~----~------------~-------~--~----~

3. Android Device not detected on Karmic

4. Use an android phone's GPS from a website

5. Life cycle and Oncreate clarifications

6. How to set title icon on Dialog Theme

7. How to contact device with ADB from Windows NT