Java tutorial
//package com.java2s; import android.content.Context; import android.content.pm.PackageManager; public class Main { /** * Function to check if the device has a camera or not. * @param context context of class. * @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); } }