throw Exception If Camera is Disabled - Android android.hardware

Android examples for android.hardware:Camera State

Description

throw Exception If Camera is Disabled

Demo Code

import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Context;

public class Main {

   static void throwIfCameraDisabled(Activity activity) throws Exception {
    // Check if device policy has disabled the camera.
    DevicePolicyManager dpm = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (dpm.getCameraDisabled(null)) {
      throw new Exception();
    }/*from   www  .j  ava 2s.  c o  m*/
  }

}

Related Tutorials