Android examples for android.hardware:Camera Feature
is Camera Has Permission
import java.lang.reflect.Field; import android.hardware.Camera; public class Main { public static boolean isCameraHasPermission(Camera camera) { if (camera == null) { return false; }// ww w. j av a 2 s. c o m Class cameraClass = (Class) camera.getClass(); if (cameraClass == null) { return false; } try { Field[] fs = cameraClass.getDeclaredFields(); if (fs != null) { for (int i = 0; i < fs.length; i++) { Field f = fs[i]; try { f.setAccessible(true); Object val = f.get(camera); if ("mHasPermission".equals(f.getName()) && val instanceof Boolean) { return (boolean) val; } } catch (Exception e) { // no op } } } return true; } catch (Exception e) { e.printStackTrace(); return true; } } }