Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 CameraUtils.java
 Copyright (c) 2015 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */

import android.hardware.Camera;

public class Main {
    /**
     * Checks whether this device support a front camera.
     * @return true if this device support a front camera, false otherwise
     */
    public static boolean hasFrontFacingDevice() {
        for (int i = 0; i < Camera.getNumberOfCameras(); ++i) {
            Camera.CameraInfo info = new Camera.CameraInfo();
            try {
                Camera.getCameraInfo(i, info);
                if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                    return true;
                }
            } catch (Exception e) {
                // do nothing.
            }
        }
        return false;
    }
}