Try the following:
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public void setMeteringAndFocusArea (int x1, int y1, int x2, int y2, Camera camera){ Camera.Parameters camParam = camera.getParameters(); if (cameraParameters.getMaxNumMeteringAreas() > 0){ List<Camera.Area> areas = new ArrayList<Camera.Area>(); Rect areaRect = new Rect(x1, x2, y1, y2); areas.add(new Camera.Area(areaRect, 1000)); camParam.setMeteringAreas(areas);
And don't forget to use
camera.autoFocus ();
before taking a picture, otherwise setFocusAreas () will not have any effect. See this link posted in this question for a pleasant implementation.
source share