public class CameraView extends Activity implements SurfaceHolder.Callback, OnClickListener{ private static final String TAG = "CameraTest"; Camera mCamera; boolean mPreviewRunning = false; @SuppressWarnings("deprecation") public void onCreate(Bundle icicle){ super.onCreate(icicle); Log.e(TAG, "onCreate"); getWindow().setFormat(PixelFormat.TRANSLUCENT); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.cameraview); ImageView img = (ImageView) findViewById(R.id.blankImage); if(CaptureCameraImage.isBlack) img.setBackgroundResource(android.R.color.black); else img.setBackgroundResource(android.R.color.white); mSurfaceView = (SurfaceView) findViewById(R.id.surface_camera); mSurfaceView.setOnClickListener(this); mSurfaceHolder = mSurfaceView.getHolder(); mSurfaceHolder.addCallback(this); mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState){ super.onRestoreInstanceState(savedInstanceState); } Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() { public void onPictureTaken(byte[] data, Camera camera) {
You need to call this action. Also check the line below the mCamera.takePicture code (null, mPictureCallback, mPictureCallback); It was called twice 1) If you want user interaction to be performed with the image, you need to make the first entry 2) If you do not want user interaction (he will take a picture as soon as it starts) you can find the whole project in
https://github.com/sandipmjadhav/CaptureImage
thanks
source share