1

I want to know if device supports front flash. I got the camera list from the camera manager and tried to get the front camera. How do I get the front camera if "Camera" is deprecated and how to know if it supports flash?

    import android.annotation.TargetApi;
    import android.app.Activity;
    import android.content.Context;
    import android.hardware.camera2.CameraAccessException;
    import android.hardware.camera2.CameraManager;
    import android.os.Bundle;


    public class MainActivity extends Activity {
        boolean x;
        String[] CameraList;

        @TargetApi(23)
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            CameraManager cameraManager= (CameraManager) getSys

temService(Context.CAMERA_SERVICE);
        try {
            //got the camera list-it's length is 2
          CameraList=cameraManager.getCameraIdList();
        } catch (CameraAccessException e) {
            e.printStackTrace();
        }



    }


}
Zach Bublil
  • 857
  • 10
  • 28
  • While `Camera` is deprecated, it still works, and is required for Android 4.4 and earlier. – CommonsWare Feb 22 '16 at 17:00
  • OK and how do I know if the device supports front flash – Zach Bublil Feb 22 '16 at 17:03
  • Use both implementation, check if the device have OS version < Lollipop use the deprecated API, if not use Camera2 – Gueorgui Obregon Feb 22 '16 at 17:06
  • http://stackoverflow.com/questions/2779002/how-to-open-front-camera-on-android-platform and http://stackoverflow.com/questions/28658278/how-to-get-id-of-front-facing-camera-using-camera2 for finding the front-facing camera. Use `Camera.Parameters` (original API) or `CameraCharacterstics` (`camera2` API) to find out what supported flash modes are for that camera. – CommonsWare Feb 22 '16 at 17:08
  • Here's your answer : http://stackoverflow.com/questions/16400910/android-test-if-front-camera-supports-flash – marshallino16 Feb 22 '16 at 17:36

0 Answers0