1

我想知道设备是否支持前置闪光灯。我从摄像头管理器那里得到了摄像头列表,并试图获取前置摄像头。如果不推荐使用“相机”,我如何获得前置摄像头以及如何知道它是否支持闪光灯?

    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();
        }



    }


}
4

0 回答 0