Android examples for android.hardware:Front Camera
Check if hardware has front or back Camera
import android.content.Context; import android.content.pm.PackageManager; import android.os.Build; public class Main{ /**/*ww w.j a va2 s . com*/ * @param context * the application context * @return true if the device has any camera, false else */ public static boolean hasCameraAny(Context context) { if (hasCameraBack(context) || hasCameraFront(context)) { return true; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY); } return false; } /** * @param context * 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); } /** * @param context * the application context * @return true if the device has a rear camera, false else */ public static boolean hasCameraBack(Context context) { PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA); } }