Example usage for android.content.pm PackageManager FEATURE_CAMERA

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

Introduction

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

Prototype

String FEATURE_CAMERA

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

Click Source Link

Document

Feature for #getSystemAvailableFeatures and #hasSystemFeature : The device has a camera facing away from the screen.

Usage

From source file:Main.java

/** Check if this device has a camera */
public static boolean checkCameraHardwareIsPresent(Context context) {
    if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        // this device has a camera
        return true;
    } else {// w w  w  . j  av  a  2 s .c  o  m
        // no camera on this device
        return false;
    }
}

From source file:Main.java

/**
 * @param context invoking context/*from   ww w . j a  va 2 s  . co m*/
 * @return info about does device support Camera
 */
public static boolean isDeviceSupportCamera(Context context) {
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);

}

From source file:Main.java

/**
 * Checking device has camera hardware or not
 *//*from  w ww  .j  a  v a2s  . com*/
public static boolean isDeviceSupportCamera(Context context) {
    // this device has a camera
    return context.getApplicationContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}

From source file:Main.java

/**
 * @param packageManager/*w  ww  . ja  v  a2  s .  c o  m*/
 * @return true <b>if the device support camera</b><br/>
 * false <b>if the device doesn't support camera</b>
 */
public static boolean isCameraSupported(PackageManager packageManager) {
    // if device support camera?
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        return true;
    }
    return false;
}

From source file:Main.java

/** Check if this device has a camera */
private static boolean checkCameraHardware(Context context) {
    if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        // this device has a camera
        return true;
    } else {/* w ww  .  j  a  va 2 s .  co m*/
        // no camera on this device
        Log.d(TAG, "no camera on this device");
        return false;
    }
}

From source file:Main.java

/**
 * Function to check if the device has a camera or not.
 * @param context context of class.//from www.  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 hasCamera(Context context) {
    if (context == null || context.getPackageManager() == null) {
        throw new IllegalArgumentException("Context and package manager must not be null");
    }/*  w  w w.  ja  v a  2s  .  c  om*/
    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 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 {//  w ww.j  a  v  a 2s. co  m
        return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)
                || packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    }
}

From source file:Main.java

/** 
 * @return true if this device has a camera  
 */// w ww .java  2s. com
public static boolean hasCamera(Context context) {
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}

From source file:Main.java

/**
 * Check if this device has a camera/*from  www. ja v a 2  s .co  m*/
 */
public static boolean checkCameraHardware(Context context) {
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
}