Check if hardware has Camera - Android android.hardware

Android examples for android.hardware:Camera State

Description

Check if hardware has Camera

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);
  }// w  w w .  java  2  s. co  m

}

Related Tutorials