Question

Is it possible to take a picture with out opening camera ? I tried with intents but its opening camera, but i don't want to open camera.I tried following

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, 1);

and after that receiving the activity.But how to do with out opening the camera?

Was it helpful?

Solution

Yes it is possible for that use SurfaceHolder.Callback Interface . And

        @TargetApi(9)
    public void surfaceCreated(SurfaceHolder holder){
        Log.e(TAG, "surfaceCreated");
        mCamera = Camera.open(CaptureCameraImage.cameraID);
    }

    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
        Log.e(TAG, "surfaceChanged");

        if (mPreviewRunning){
            mCamera.stopPreview();
        }

        try{
            mCamera.setPreviewDisplay(holder);
        }catch (Exception e){
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        mCamera.startPreview();
        mPreviewRunning = true;
        mCamera.takePicture(null, mPictureCallback, mPictureCallback);
    }

    public void surfaceDestroyed(SurfaceHolder holder) {
        Log.e(TAG, "surfaceDestroyed");
        //mCamera.stopPreview();
        //mPreviewRunning = false;
        //mCamera.release();
    }

For that use dummy surfaceview so you can take picture from background.

like

 SurfaceView dummy=new SurfaceView(context);
  dummy.addCallback(this);

And do some reasearch work on this dummy Surfaceview.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top