private boolean setCameraPictureSize(
     String candidate, List<Size> supported, Parameters parameters) {
   int index = candidate.indexOf('x');
   if (index == NOT_FOUND) return false;
   int width = Integer.parseInt(candidate.substring(0, index));
   int height = Integer.parseInt(candidate.substring(index + 1));
   for (Size size : supported) {
     if (size.width == width && size.height == height) {
       parameters.setPictureSize(width, height);
       return true;
     }
   }
   return false;
 }
 /**
  * Listener for on screen clicks. Workaround for bug in 2.3.X: we stop the preview and start a new
  * one against a null surface Then take the picture.
  */
 public void onClick(View v) {
   if ((mCamera != null) && (!mCapturing)) {
     mCapturing = true;
     mCamera.stopPreview();
     mCamera.setPreviewCallback(null);
     Parameters params = mCamera.getParameters();
     Size defaultSize = params.getSupportedPictureSizes().get(0);
     int[] size = PanoCamera.getCameraSize(mContext, defaultSize.width, defaultSize.height);
     Log.d("OpenCV_Base", "Size is " + size[0] + "x" + size[1]);
     params.setPictureSize(size[0], size[1]);
     mCamera.setParameters(params);
     try {
       mCamera.setPreviewDisplay(null);
       mCamera.startPreview();
       mCamera.takePicture(null, null, jpegCallback);
     } catch (IOException e) {
       // Camera is unavailable, don't take a picture
       // TODO: alert user
     }
   }
 }
  // TODO >>>> Set Picture Size From Screen
  public void setPictureSizeOfScreenAndPreviewsize() {
    Parameters params = cam.getParameters();
    List<Camera.Size> sizes = params.getSupportedPictureSizes();
    boolean sizesupportofscreen = false;
    for (int i = 0; i < sizes.size(); i++) {
      PrintLog.print(
          activity.getApplicationContext(),
          sizes.get(i).width
              + "|"
              + sizes.get(i).height
              + " : : "
              + Deviceinfo.getDeviceScreenSize(activity)[0]
              + "|"
              + Deviceinfo.getDeviceScreenSize(activity)[1]);

      if ((sizes.get(i).width == Deviceinfo.getDeviceScreenSize(activity)[0]
              && sizes.get(i).height == Deviceinfo.getDeviceScreenSize(activity)[1])
          || (sizes.get(i).width == Deviceinfo.getDeviceScreenSize(activity)[1]
              && sizes.get(i).height == Deviceinfo.getDeviceScreenSize(activity)[0])) {
        if (Deviceinfo.getDeviceScreenOrentation(activity).equals("portrait")) {
          PrintLog.print(
              activity.getApplicationContext(),
              sizes.get(i).width + "|" + sizes.get(i).height + " is support!");
          params.setPictureSize(sizes.get(i).width, sizes.get(i).height);

          if (getFrontCameraStatus()) { // Front Facing Detect
            params.setPreviewSize(sizes.get(i).width, sizes.get(i).height);
          }

          if (getBackCameraStatus()) { // back Facing Detect
            params.setPreviewSize(
                Integer.parseInt(devicearraydata[4]), Integer.parseInt(devicearraydata[3]));
          }

          try {
            cam.setParameters(params);
          } catch (Exception e) {
            PrintLog.print(activity, "Can't setPictureSizeOfScreen");
          }
        }
        sizesupportofscreen = true;
        break;

      } else {
        sizesupportofscreen = false;
      }
    }
    //
    // if(!sizesupportofscreen){
    // params.setPreviewSize(1200,1600);
    // try{
    // cam.setParameters(params);
    // }catch (Exception e){
    // PrintLog.print(activity,"Can't setPictureSizeOfScreen");
    // }
    //
    // }

    if (Deviceinfo.BUILD_MODEL.equals("GT-S5360")) {

      params.setPictureSize(1280, 960);
      try {
        cam.setParameters(params);
      } catch (Exception e) {
        PrintLog.print(activity, "Can't setPictureSizeOfScreen");
      }
    }
  }