List of utility methods to do Camera Get
Camera | getDefaultFrontFacingCameraInstance() get Default Front Facing Camera Instance return getDefaultCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
|
int | getNumberOfCameras() get Number Of Cameras return Camera.getNumberOfCameras();
|
Camera | getDefaultBackFacingCameraInstance() get Default Back Facing Camera Instance return getDefaultCamera(Camera.CameraInfo.CAMERA_FACING_BACK);
|
int | getCameraRotation(final Context context) get Camera Rotation final WindowManager windowManager = (WindowManager) context .getSystemService(Context.WINDOW_SERVICE); int rotation = windowManager.getDefaultDisplay().getRotation(); final DisplayMetrics metrics = new DisplayMetrics(); windowManager.getDefaultDisplay().getMetrics(metrics); final int width = metrics.widthPixels; final int height = metrics.heightPixels; if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) ... |
Integer | indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio) index Of Closest Zoom List<Integer> ratios = parameters.getZoomRatios(); Log.i(TAG, "Zoom ratios: " + ratios); int maxZoom = parameters.getMaxZoom(); if (ratios == null || ratios.isEmpty() || ratios.size() != maxZoom + 1) { Log.w(TAG, "Invalid zoom ratios!"); return null; double target100 = 100.0 * targetZoomRatio; double smallestDiff = Double.POSITIVE_INFINITY; int closestIndex = 0; for (int i = 0; i < ratios.size(); i++) { double diff = Math.abs(ratios.get(i) - target100); if (diff < smallestDiff) { smallestDiff = diff; closestIndex = i; Log.i(TAG, "Chose zoom ratio of " + (ratios.get(closestIndex) / 100.0)); return closestIndex; |
Camera.Size | getLowestResolution(Camera.Parameters cp) get Lowest Resolution List<Camera.Size> sl = cp.getSupportedVideoSizes(); if (sl == null) sl = cp.getSupportedPictureSizes(); Camera.Size small = sl.get(0); for (Camera.Size s : sl) { if ((s.height * s.width) < (small.height * small.width)) small = s; return small; |
void | launchCamera(Activity activity) launch Camera Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
camera.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
Uri.fromFile(getFileToStoreCameraResult()));
activity.startActivityForResult(camera, CAMERA_RESULT);
|