Code to check Camera exists or not in Android Device

PackageManager pm = this.getPackageManager();

        if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
            System.out.println("---------has camera------");
            System.out.println("---------has no camera------");


//It would be safer to use the constant PackageManager.FEATURE_CAMERA_FRONT
        //but since it is not defined for Android 2.2, I substituted the literal value
        frontCam = pm.hasSystemFeature("");
        rearCam = pm.hasSystemFeature(PackageManager.FEATURE_CAMERA);
        if(frontCam || rearCam){


Popular posts from this blog

Custom Dialog with no title and full screen in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard

Best working code to set Date limits on Date Picker Dialog,in Android