Example usage for android.content.pm PackageManager FEATURE_CAMERA_FRONT

List of usage examples for android.content.pm PackageManager FEATURE_CAMERA_FRONT

Introduction

In this page you can find the example usage for android.content.pm PackageManager FEATURE_CAMERA_FRONT.

Prototype

String FEATURE_CAMERA_FRONT

To view the source code for android.content.pm PackageManager FEATURE_CAMERA_FRONT.

Click Source Link

Document

Feature for #getSystemAvailableFeatures and #hasSystemFeature : The device has a front facing camera.

Usage

From source file:Main.java

public static boolean checkForFrontCam(Context context) {
    if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT)) {
        return true;
    } else {/*from www .j av  a2  s  .c om*/
        return false;
    }
}

From source file:Main.java

public static boolean hasCamera(Context context) {
    PackageManager pm = context.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)
            || pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
}

From source file:Main.java

/**
 * @param context//w  ww  .  j  av a  2  s . com
 *         the application context
 * @return true if the device has a front camera, false else
 */
public static boolean hasCameraFront(Context context) {
    PackageManager pm = context.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
}

From source file:Main.java

public static boolean isCameraFrontEnable(Context context) {
    PackageManager pm = (PackageManager) context.getPackageManager();
    FeatureInfo[] features = pm.getSystemAvailableFeatures();
    for (FeatureInfo f : features) {
        if (PackageManager.FEATURE_CAMERA_FRONT.equals(f.name)) {
            return true;
        }/* ww  w .j a  v  a  2 s  .  co m*/
    }
    return false;
}

From source file:Main.java

/**
 * Function to check if the device has a camera or not.
 * @param context context of class./*from w w  w .  j a  v a  2s .  co m*/
 * @return true if the camera is present and false otherwise.
 */
public static boolean isCameraPresent(Context context) {
    PackageManager packageManager = context.getPackageManager();
    return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
            || packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
}

From source file:Main.java

public static boolean doesDeviceSupportCameras(@NonNull Context context) {

    final PackageManager packageManager = context.getPackageManager();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);
    } else {//from   w w  w . j a v  a  2 s. c  om
        return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
                || packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    }
}

From source file:Main.java

public static boolean hasCamera(Context context) {
    if (context == null || context.getPackageManager() == null) {
        throw new IllegalArgumentException("Context and package manager must not be null");
    }/*from  ww  w .  j  a  va 2  s . c  o m*/
    PackageManager pm = context.getPackageManager();
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        return true;
    } else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
        return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    } else {
        return false;
    }
}

From source file:Main.java

public static boolean isFrontCameraSupported(Context ctx) {
    PackageManager pm = ctx.getPackageManager();
    return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
}

From source file:Main.java

public static boolean hasCameraAvailable(Context context) {
    try {/* w  w  w  . j ava  2s. c  o  m*/
        return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)
                || context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    } catch (Exception e) {
        return false;
    }
}

From source file:org.alfresco.mobile.android.application.capture.VideoCapture.java

@Override
public boolean hasDevice() {
    return (parentActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)
            || parentActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT));
}