1

I am developing an app in which I want to open front camera on button click (if front camera is present on that device).

I have use this code which works for me on Asus Tablet having OS 3.2.1. But same code is not working on OS 4.2.1.

I want the code which works on all android versions. Please help me in this problem.

Following is my code-

Intent takePictureIntent = new Intent(
                MediaStore.ACTION_IMAGE_CAPTURE);

takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                            Uri.fromFile(f));
                    Log.v("", "Camera Id-" + camId);

                    if (!TextUtils.isEmpty(camera)) {
                        if (camera.equalsIgnoreCase("Front")) {
                            Log.v("", "Inside if");
                            takePictureIntent.putExtra(
                                    "android.intent.extras.CAMERA_FACING",
                                    Camera.CameraInfo.CAMERA_FACING_FRONT);

                        } else {
                            Log.v("", "Inside else");
                            takePictureIntent.putExtra(
                                    "android.intent.extras.CAMERA_FACING",
                                    Camera.CameraInfo.CAMERA_FACING_BACK);

                        }
                    }
startActivityForResult(takePictureIntent, actionCode);
Aniket Bhosale
  • 651
  • 2
  • 11
  • 14

0 Answers0