List of usage examples for android.content.pm PackageManager FEATURE_CAMERA_FLASH
String FEATURE_CAMERA_FLASH
To view the source code for android.content.pm PackageManager FEATURE_CAMERA_FLASH.
Click Source Link
From source file:org.protocoderrunner.apprunner.api.PDevice.java
@ProtoMethod(description = "Check if the device has camera flash", example = "") public boolean hasCameraFlash() { PackageManager pm = getContext().getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); }
From source file:com.czh.testmpeg.videorecord.CameraActivity.java
public void setFlashMode(String mode) { try {/*from w w w . j av a2 s. com*/ if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH) && mCamera != null && !cameraFront) { mPreview.setFlashMode(mode); mPreview.refreshCamera(mCamera); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), R.string.changing_flashLight_mode, Toast.LENGTH_SHORT).show(); } }
From source file:org.durka.hallmonitor.CoreStateManager.java
public boolean getDeviceHasFlash() { deviceHasFlash = mAppContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); return deviceHasFlash; }
From source file:org.uguess.android.sysinfo.SiragonManager.java
private boolean getAvailableFlash() { if (PackageManager.FEATURE_CAMERA_FLASH != null) { return true; } return false; }
From source file:com.android.launcher3.Utilities.java
public static void turnOnFlashLight(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { CameraManager camManager = (CameraManager) context.getApplicationContext() .getSystemService(Context.CAMERA_SERVICE); String cameraId = null;//from ww w . java2s . c om try { cameraId = camManager.getCameraIdList()[0]; camManager.setTorchMode(cameraId, true); isFlashLightOn = true; } catch (CameraAccessException e) { isFlashLightOn = false; e.printStackTrace(); } } else { try { if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { Camera cam = Camera.open(); Camera.Parameters p = cam.getParameters(); p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH); cam.setParameters(p); cam.startPreview(); isFlashLightOn = true; } } catch (Exception e) { e.printStackTrace(); isFlashLightOn = false; } } }
From source file:com.android.launcher3.Utilities.java
public static void turnOffFlashLight(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { CameraManager camManager = (CameraManager) context.getApplicationContext() .getSystemService(Context.CAMERA_SERVICE); String cameraId = null;/*from w ww . j a v a2 s.c om*/ try { cameraId = camManager.getCameraIdList()[0]; camManager.setTorchMode(cameraId, false); isFlashLightOn = false; } catch (CameraAccessException e) { isFlashLightOn = true; e.printStackTrace(); } } else { try { if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH)) { cam.stopPreview(); cam.release(); cam = null; isFlashLightOn = false; } } catch (Exception e) { isFlashLightOn = true; e.printStackTrace(); } } }
From source file:com.simadanesh.isatis.ScreenSlideActivity.java
private void switchFlash() { boolean hasFlash = getApplicationContext().getPackageManager() .hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH); if (!hasFlash) { // device doesn't support flash // Show alert message and close the application AlertDialog alert = new AlertDialog.Builder(this).create(); alert.setTitle("Error"); alert.setMessage("Sorry, your device doesn't support flash light!"); alert.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { }/* ww w .ja v a 2 s .com*/ }); alert.show(); return; } if (isFlashOn) { // turn off flash turnOffFlash(); } else { // turn on flash turnOnFlash(); } }