本文整理汇总了Java中com.android.camera.CameraDisabledException类的典型用法代码示例。如果您正苦于以下问题:Java CameraDisabledException类的具体用法?Java CameraDisabledException怎么用?Java CameraDisabledException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CameraDisabledException类属于com.android.camera包,在下文中一共展示了CameraDisabledException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openCamera
import com.android.camera.CameraDisabledException; //导入依赖的package包/类
public static CameraManager.CameraProxy openCamera(
Activity activity, final int cameraId,
Handler handler, final CameraManager.CameraOpenErrorCallback cb) {
try {
throwIfCameraDisabled(activity);
return CameraHolder.instance().open(handler, cameraId, cb);
} catch (CameraDisabledException ex) {
handler.post(new Runnable() {
@Override
public void run() {
cb.onCameraDisabled(cameraId);
}
});
}
return null;
}
示例2: checkAndOpenCamera
import com.android.camera.CameraDisabledException; //导入依赖的package包/类
private static void checkAndOpenCamera(Context context, CameraAgent cameraManager,
final int cameraId, Handler handler, final CameraAgent.CameraOpenCallback cb) {
Log.v(TAG, "checkAndOpenCamera");
try {
CameraUtil.throwIfCameraDisabled(context);
cameraManager.openCamera(handler, cameraId, cb);
} catch (CameraDisabledException ex) {
handler.post(new Runnable() {
@Override
public void run() {
cb.onCameraDisabled(cameraId);
}
});
}
}
示例3: throwIfCameraDisabled
import com.android.camera.CameraDisabledException; //导入依赖的package包/类
public static void throwIfCameraDisabled(Context context) throws CameraDisabledException {
// Check if device policy has disabled the camera.
DevicePolicyManager dpm =
(DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (dpm.getCameraDisabled(null)) {
throw new CameraDisabledException();
}
}
示例4: throwIfCameraDisabled
import com.android.camera.CameraDisabledException; //导入依赖的package包/类
private static void throwIfCameraDisabled(Activity activity) throws CameraDisabledException {
// Check if device policy has disabled the camera.
DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(
Context.DEVICE_POLICY_SERVICE);
if (dpm.getCameraDisabled(null)) {
throw new CameraDisabledException();
}
}