Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c = Camera.open(findFrontFacingCamera());
- SurfaceView view = new SurfaceView(this);
- try {
- c.setPreviewDisplay(view.getHolder());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- c.startPreview();
- c.takePicture(null, null, null, new PicClick(this));
- }
- private int findFrontFacingCamera() {
- int cameraId = -1;
- // Search for the front facing camera
- int numberOfCameras = Camera.getNumberOfCameras();
- for (int i = 0; i < numberOfCameras; i++) {
- CameraInfo info = new CameraInfo();
- Camera.getCameraInfo(i, info);
- if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
- Log.d("TAG", "Camera found");
- cameraId = i;
- break;
- }
- }
Add Comment
Please, Sign In to add comment