Check if a device has Camera via PackageManager - Android Camera

Android examples for Camera:Camera Feature

Description

Check if a device has Camera via PackageManager

Demo Code


import android.content.Context;
import android.content.pm.PackageManager;

public class Main {
  public static boolean hasCamera(Context context) {
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)
        || context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
  }//from  www  .java 2 s .c o  m
}

Related Tutorials