Esempio n. 1
0
  protected void onListItemClick(ListView l, View v, int position, long id) {
    ProfilerAudioAdapter profileAudioAdapter = (ProfilerAudioAdapter) getListAdapter();
    String selectedValue = profileAudioAdapter.getItem(position);
    Toast.makeText(this, selectedValue, Toast.LENGTH_SHORT).show();

    GetFile task = new GetFile();
    String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
    File folder = new File(extStorageDirectory, "Audio");
    folder.mkdir();
    ArrayList<String> params = new ArrayList<String>();
    params.add(fileLocation[position]);
    params.add(fileName[position]);
    params.add(String.valueOf(folder));
    task.execute(new ArrayList[] {params});

    try {
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);
      File fileToRead = new File(folder + "/" + fileName[position]);
      Uri uri = Uri.fromFile(fileToRead.getAbsoluteFile());
      intent.setDataAndType(uri, "audio/mp3");
      startActivity(intent);
    } catch (ActivityNotFoundException activityNotFoundException) {
      activityNotFoundException.printStackTrace();
      Toast.makeText(this, "There doesn't seem to be an Audio player installed.", Toast.LENGTH_LONG)
          .show();
    } catch (Exception ex) {
      ex.printStackTrace();
      Toast.makeText(this, "Cannot open the selected file.", Toast.LENGTH_LONG).show();
    }
  }
 protected void doTakePhoto() {
   try {
     Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
     startActivityForResult(cameraIntent, CAMERA_WITH_DATA);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
 /**
  * 调用系统的拍照界面去拍照,并获取结果
  *
  * @param
  * @param filePath 保存相片的全路径
  * @param requestCode
  */
 public static void capturePhotoForResult(FragmentBase a, String filePath, int requestCode) {
   Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   it.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePath)));
   try {
     a.startActivityForResult(it, requestCode);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
 private void actUCCW() {
   Uri uccwuriString = Uri.parse(getString(R.string.uccw_link));
   Intent uccwIntent = new Intent("android.intent.action.VIEW", uccwuriString);
   try {
     startActivity(uccwIntent);
   } catch (ActivityNotFoundException e2) {
     e2.printStackTrace();
   }
 };
 public static void capturePhotoForResult(Activity a, Uri uri, int requestCode) {
   Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
   it.putExtra(MediaStore.EXTRA_OUTPUT, uri);
   try {
     a.startActivityForResult(it, requestCode);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 6
0
 public void showChooser(View view) {
   Intent target = FileUtils.createGetHtmlContentIntent();
   Intent intent = Intent.createChooser(target, getString(R.string.choose_program));
   try {
     startActivityForResult(intent, REQUEST_CODE);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
 private void actZooper() {
   Uri zooperuriString = Uri.parse(getString(R.string.zooper_link));
   Intent zooperIntent = new Intent("android.intent.action.VIEW", zooperuriString);
   try {
     startActivity(zooperIntent);
   } catch (ActivityNotFoundException e2) {
     e2.printStackTrace();
   }
 };
  // NOTE: Currently not reentrant / doesn't support concurrent requests
  @ReactMethod
  public void launchImageLibrary(final ReadableMap options, final Callback callback) {
    response = Arguments.createMap();

    if (options.hasKey("noData")) {
      noData = options.getBoolean("noData");
    }
    if (options.hasKey("maxWidth")) {
      maxWidth = options.getInt("maxWidth");
    }
    if (options.hasKey("maxHeight")) {
      maxHeight = options.getInt("maxHeight");
    }
    if (options.hasKey("aspectX")) {
      aspectX = options.getInt("aspectX");
    }
    if (options.hasKey("aspectY")) {
      aspectY = options.getInt("aspectY");
    }
    if (options.hasKey("quality")) {
      quality = (int) (options.getDouble("quality") * 100);
    }
    tmpImage = true;
    if (options.hasKey("storageOptions")) {
      tmpImage = false;
    }
    if (options.hasKey("allowsEditing")) {
      allowEditing = options.getBoolean("allowsEditing");
    }
    forceAngle = false;
    if (options.hasKey("angle")) {
      forceAngle = true;
      angle = options.getInt("angle");
    }
    if (options.hasKey("assetProperties")) {
      assetProperties = options.getBoolean("assetProperties");
    }

    Intent libraryIntent =
        new Intent(
            Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

    if (libraryIntent.resolveActivity(mMainActivity.getPackageManager()) == null) {
      response.putString("error", "Cannot launch photo library");
      callback.invoke(response);
      return;
    }

    mCallback = callback;

    try {
      mMainActivity.startActivityForResult(libraryIntent, REQUEST_LAUNCH_IMAGE_LIBRARY);
    } catch (ActivityNotFoundException e) {
      e.printStackTrace();
    }
  }
Esempio n. 9
0
 /**
  * 拍照获取图片
  *
  * @param cropImg
  */
 private void doTakePhoto() {
   try {
     final Intent intent = getTakePickIntent(mCurrentPhotoFile);
     if (fragmentContext != null) fragmentContext.startActivityForResult(intent, CAMERA_WITH_DATA);
     else activityContext.startActivityForResult(intent, CAMERA_WITH_DATA);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
     Toast.makeText(activityContext, "图片获取失败", _2000).show();
   }
 }
 @Override
 public void openUri(Activity activity, Uri uri) {
   Toast.makeText(activity, R.string.custom_tabs_failed, Toast.LENGTH_SHORT).show();
   try {
     activity.startActivity(new Intent(Intent.ACTION_VIEW, uri));
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
     Toast.makeText(activity, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
   }
 }
Esempio n. 11
0
 public static void startActivity(Context cxt, String user) {
   Uri uri = Uri.parse("query://");
   Intent intent = new Intent(ACTION, uri);
   intent.putExtra("workercode", user);
   try {
     cxt.startActivity(intent);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 12
0
 public static void openMarketDetails(final Context context, String packageName) {
   try {
     Intent intent = new Intent(Intent.ACTION_VIEW);
     intent.setData(Uri.parse("market://details?id=" + packageName));
     intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     context.startActivity(intent);
   } catch (final ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 13
0
 public static void startActivity(Context cxt) {
   //		String action = "com.ccssoft.subsystem.KEY_LOGIN";
   Uri uri = Uri.parse("query://");
   Intent intent = new Intent(ACTION, uri);
   intent.putExtra("workercode", "gzadmin");
   try {
     cxt.startActivity(intent);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 14
0
 // 请求Gallery程序
 private void doPickPhotoFromGallery() {
   try {
     // Launch picker to choose photo for selected contact
     final Intent intent = getPhotoPickIntent();
     if (fragmentContext != null) fragmentContext.startActivityForResult(intent, PHOTO_PICKED);
     else activityContext.startActivityForResult(intent, PHOTO_PICKED);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
     Toast.makeText(activityContext, "图片获取失败", _2000).show();
   }
 }
Esempio n. 15
0
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    int id = v.getId();
    if (id == R.id.button_camera) {

      String sdStatus = Environment.getExternalStorageState();
      if (!sdStatus.equals(Environment.MEDIA_MOUNTED)) { //
        Log.d("MainActivity", "SD card is not avaiable/writeable right now.");
        return;
      }
      try {
        File dir = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera");
        if (!dir.exists()) dir.mkdirs();

        String name =
            DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg";

        File f = new File(dir, name);
        Intent intent0 = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent0.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
        intent0.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

        Intent intent = Intent.createChooser(intent0, null);

        mCameraPicPath = f.getAbsolutePath();

        startActivityForResult(intent, req_capture);

      } catch (ActivityNotFoundException e) {
        e.printStackTrace();
      }

    } else if (id == R.id.button_op) {

      if (mIndex == view_all) {
        if (mViewAll.haveData()) mViewAll.setEditMode(true);
      } else if (mIndex == view_like) {
        if (mViewLike.haveData()) mViewLike.setEditMode(true);
      }

    } else if (id == R.id.button_menu) {

      {
        showSettingMenu();
      }
    } else if (id == R.id.button_all) {
      mViewPager.setCurrentItem(view_all);
    } else if (id == R.id.button_dir) {
      mViewPager.setCurrentItem(view_dir);
    } else if (id == R.id.button_like) {
      mViewPager.setCurrentItem(view_like);
    }
  }
  public void onPhotoPickerItemSelected(int item) {
    Intent intent;

    switch (item) {
      case MyRunsDialogFragment.ID_PHOTO_PICKER_FROM_CAMERA:
        // Take photo from camera,
        // Construct an intent with action
        // MediaStore.ACTION_IMAGE_CAPTURE
        intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Construct temporary image path and name to save the taken
        // photo
        mImageCaptureUri =
            Uri.fromFile(
                new File(
                    Environment.getExternalStorageDirectory(),
                    "tmp_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
        intent.putExtra("return-data", true);
        try {
          // Start a camera capturing activity
          // REQUEST_CODE_TAKE_FROM_CAMERA is an integer tag you
          // defined to identify the activity in onActivityResult()
          // when it returns
          startActivityForResult(intent, REQUEST_CODE_TAKE_FROM_CAMERA);
        } catch (ActivityNotFoundException e) {
          e.printStackTrace();
        }
        isTakenFromCamera = true;
        break;

      case MyRunsDialogFragment.ID_PHOTO_FROM_GALLERY:
        intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        try {
          startActivityForResult(intent, REQUEST_CODE_FROM_GALLERY);
        } catch (ActivityNotFoundException e) {
          e.printStackTrace();
        }
      default:
        return;
    }
  }
Esempio n. 17
0
  private void activateRecognize() {
    try {
      Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
      intent.putExtra(
          RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
      intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Delon-kun Voice Recognition");
      startActivityForResult(intent, REQUEST_CODE);

    } catch (ActivityNotFoundException e) {
      e.printStackTrace();
    }
  }
 private void actExtras2() {
   Uri extras2uriString =
       Uri.parse(
           getString(
               R.string.extras2_link)); // use this to link to your UCCW skins on Play or Website
   Intent extras2Intent = new Intent("android.intent.action.VIEW", extras2uriString);
   try {
     startActivity(extras2Intent);
   } catch (ActivityNotFoundException e2) {
     e2.printStackTrace();
   }
 };
 private void actPlay() {
   Uri marketuriString = Uri.parse(getString(R.string.play_link));
   Intent playintent = new Intent(Intent.ACTION_VIEW, marketuriString);
   try {
     startActivity(playintent);
   } catch (ActivityNotFoundException e2) {
     e2.printStackTrace();
     Toast.makeText(
             getActivity().getApplicationContext(), "Play Store not found!", Toast.LENGTH_LONG)
         .show();
   }
 };
 /**
  * 通过何种方式获取图片 PHOTO_PICKED_WITH_DATA 相册 CAMERA_WITH_DATA 相机
  *
  * @param way 判断方式
  */
 public static void ChooseWay(Context context, int way) {
   if (CameraUtil.PHOTO_PICKED_WITH_DATA == way) {
     try {
       Intent intent = CameraUtil.getPhotoPickIntent();
       ((Activity) context).startActivityForResult(intent, CameraUtil.PHOTO_PICKED_WITH_DATA);
     } catch (ActivityNotFoundException e) {
       e.printStackTrace();
     }
   }
   if (CameraUtil.CAMERA_WITH_DATA == way) {
     try {
       if (!CameraUtil.PHOTO_DIR.exists()) {
         CameraUtil.PHOTO_DIR.mkdirs();
       }
       mCurrentPhotoFile = new File(CameraUtil.PHOTO_DIR, CameraUtil.getPhotoFileName());
       Intent intent = CameraUtil.getTakePickIntent(mCurrentPhotoFile);
       ((Activity) context).startActivityForResult(intent, CameraUtil.CAMERA_WITH_DATA);
     } catch (ActivityNotFoundException e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 21
0
 private void showFileChooser() {
   // Intent intent = new Intent();
   Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
   intent.setType("image/*");
   intent.setAction(Intent.ACTION_GET_CONTENT);
   try {
     // startActivityForResult(Intent.createChooser(intent,"Complete action using"), UPDATE_PIC);
     startActivityForResult(intent, UPDATE_PIC);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
     Snackbar.make(profileImgView, "Activity not found", Snackbar.LENGTH_LONG)
         .setAction("Action", null)
         .show();
   }
 }
Esempio n. 22
0
 /**
  * 跳转系统网络设置界面
  *
  * @param context
  */
 public static boolean startActivitySettingWireless(Context context) {
   Intent intent = new Intent();
   if (Build.VERSION.SDK_INT < 14) {
     intent.setAction(Settings.ACTION_WIRELESS_SETTINGS);
   } else {
     intent.setAction(Settings.ACTION_SETTINGS);
   }
   try {
     context.startActivity(intent);
     return true;
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   } catch (SecurityException e) {
     e.printStackTrace();
   }
   return false;
 }
Esempio n. 23
0
  public void openWordFile2(View view) {
    Intent intent = new Intent();
    intent.setAction("com.olivephone.edit");
    String fileMimeType = "application/vnd.ms-word";

    Uri uri = Uri.fromFile(new File(PATH + "针推科健康指导.doc"));
    intent.setDataAndType(uri, fileMimeType);

    try {
      startActivity(intent);
    } catch (ActivityNotFoundException e) {
      // 检测到系统尚未安装OliveOffice的apk程序
      // 请先到www.olivephone.com/e.apk下载并安装
      ToastAndLog.debug(PATH);
      ToastAndLog.makeText("检测到系统尚未安装OliveOffice的apk程序");
      e.printStackTrace();
    }
  }
Esempio n. 24
0
  public void searchOrDownloadPlugin(
      final String packageName, final int type, final boolean search) {
    logger.info("searchOrDownloadPlugin: " + packageName + ", search: " + search);

    Tracker.initializeTracking(getBaseContext(), packageName, type, search);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (search) intent.setData(Uri.parse("market://search?q=" + packageName));
    else intent.setData(Uri.parse("market://details?id=" + packageName));

    try {
      getBaseContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
      Toast.makeText(getBaseContext(), R.string.feather_activity_not_found, Toast.LENGTH_SHORT)
          .show();
      e.printStackTrace();
    }
  }
Esempio n. 25
0
 public static void openWeiChatApp(Context context) {
   if (null == context) {
     return;
   }
   if (!checkWeiChatApp(context)) {
     ShowToast.showShortToast(context, "未安装微信哦~");
   }
   try {
     Intent intent = new Intent();
     intent.setClassName(WEIXIN_PACKAGENAME, WEIXIN_LAUNCHER_UI);
     intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
     context.startActivity(intent);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 private void showChosen(final int type, File image, int fragmentId) {
   if (type == REQUEST_PICK_SYSTEM) {
     ListView listie = new ListView(mParent);
     listie.setAdapter(new IconAdapter());
     final Dialog dialog = new Dialog(mParent);
     dialog.setTitle(R.string.icon_picker_choose_icon_title);
     dialog.setContentView(listie);
     listie.setOnItemClickListener(
         new OnItemClickListener() {
           @Override
           public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
             Intent in = new Intent();
             in.putExtra(
                 "resource_name", ((IconAdapter) parent.getAdapter()).getItemReference(position));
             mIconListener.iconPicked(type, Activity.RESULT_OK, in);
             dialog.dismiss();
           }
         });
     dialog.show();
   } else if (type == REQUEST_PICK_GALLERY) {
     Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
     intent.setType("image/*");
     intent.putExtra("crop", "true");
     intent.putExtra("scale", true);
     intent.putExtra("scaleUpIfNeeded", false);
     intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
     intent.putExtra("aspectX", 1);
     intent.putExtra("aspectY", 1);
     intent.putExtra("outputX", 162);
     intent.putExtra("outputY", 162);
     try {
       intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
       intent.putExtra("return-data", false);
       startFragmentOrActivityForResult(intent, type, fragmentId);
     } catch (ActivityNotFoundException e) {
       e.printStackTrace();
     }
   } else if (type == REQUEST_PICK_ICON_PACK) {
     Intent iconPack = new Intent(ICON_ACTION);
     startFragmentOrActivityForResult(iconPack, type, fragmentId);
   }
 }
 public void takePhoto() {
   String status = Environment.getExternalStorageState();
   if (status.equals(Environment.MEDIA_MOUNTED)) {
     try {
       localTempImageFileName = "";
       localTempImageFileName = String.valueOf((new Date()).getTime()) + ".png";
       File filePath = FILE_PIC_SCREENSHOT;
       if (!filePath.exists()) {
         filePath.mkdirs();
       }
       Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
       File f = new File(filePath, localTempImageFileName);
       // localTempImgDir和localTempImageFileName是自己定义的名字
       Uri u = Uri.fromFile(f);
       intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0);
       intent.putExtra(MediaStore.EXTRA_OUTPUT, u);
       startActivityForResult(intent, FLAG_CHOOSE_PHONE);
     } catch (ActivityNotFoundException e) {
       e.printStackTrace();
     }
   }
 }
Esempio n. 28
0
  public void openWordFile(View view) {

    Intent intent = new Intent();

    // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    //		intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setClassName("cn.wps.moffice_eng", "cn.wps.moffice.documentmanager.PreStartActivity2");

    Uri uri = Uri.fromFile(new File(PATH + "针推科健康指导.doc"));
    //		intent.setData(uri);

    String fileMimeType = "application/vnd.ms-word";
    intent.setDataAndType(uri, fileMimeType);

    try {
      startActivity(intent);
    } catch (ActivityNotFoundException e) {
      ToastAndLog.debug(PATH);
      ToastAndLog.makeText("您没有安装指定的WPS组件");
      e.printStackTrace();
    }
  }
  public void searchOrDownloadPlugin(
      final String packageName, final int type, final boolean search) {
    logger.info("searchOrDownloadPlugin: " + packageName + ", search: " + search);

    Intent intent = new Intent(Intent.ACTION_VIEW);
    if (search) intent.setData(Uri.parse("market://search?q=" + packageName));
    else intent.setData(Uri.parse("market://details?id=" + packageName));

    try {

      String name = FeatherIntent.PluginType.getName(type);
      if (null != name) {
        HashMap<String, String> attrs = new HashMap<String, String>();
        attrs.put("assetType", name);
        Tracker.recordTag("content: addMoreClicked", attrs);
      }
      getBaseContext().startActivity(intent);
    } catch (ActivityNotFoundException e) {
      Toast.makeText(getBaseContext(), R.string.feather_activity_not_found, Toast.LENGTH_SHORT)
          .show();
      e.printStackTrace();
    }
  }
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    // robustness code
    if (mCallback == null
        || (mCameraCaptureURI == null && requestCode == REQUEST_LAUNCH_CAMERA)
        || (requestCode != REQUEST_LAUNCH_CAMERA
            && requestCode != REQUEST_LAUNCH_IMAGE_LIBRARY
            && requestCode != REQUEST_IMAGE_CROPPING)) {
      return;
    }

    // user cancel
    if (resultCode != Activity.RESULT_OK) {
      response.putBoolean("didCancel", true);
      mCallback.invoke(response);
      return;
    }

    Uri uri;
    switch (requestCode) {
      case REQUEST_LAUNCH_CAMERA:
        uri = mCameraCaptureURI;
        break;
      case REQUEST_IMAGE_CROPPING:
        uri = mCropImagedUri;
        break;
      default:
        uri = data.getData();
    }

    if (requestCode != REQUEST_IMAGE_CROPPING && allowEditing == true) {
      Intent cropIntent = new Intent("com.android.camera.action.CROP");
      cropIntent.setDataAndType(uri, "image/*");
      cropIntent.putExtra("crop", "true");

      if (aspectX > 0 && aspectY > 0) {
        // aspectX:aspectY, the ratio of width to height
        cropIntent.putExtra("aspectX", aspectX);
        cropIntent.putExtra("aspectY", aspectY);
        cropIntent.putExtra("scale", true);
      }

      // we create a file to save the result
      File imageFile = createNewFile();
      mCropImagedUri = Uri.fromFile(imageFile);
      cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCropImagedUri);

      try {
        mMainActivity.startActivityForResult(cropIntent, REQUEST_IMAGE_CROPPING);
      } catch (ActivityNotFoundException e) {
        e.printStackTrace();
      }
      return;
    }

    String realPath = getRealPathFromURI(uri);
    boolean isUrl = false;

    if (realPath != null) {
      try {
        URL url = new URL(realPath);
        isUrl = true;
      } catch (MalformedURLException e) {
        // not a url
      }
    }

    if (realPath == null || isUrl) {
      try {
        File file = createFileFromURI(uri);
        realPath = file.getAbsolutePath();
        uri = Uri.fromFile(file);
      } catch (Exception e) {
        response.putString("error", "Could not read photo");
        response.putString("uri", uri.toString());
        mCallback.invoke(response);
        return;
      }
    }

    ExifInterface exif = null;
    int CurrentAngle = 0;
    try {
      exif = new ExifInterface(realPath);
      int orientation =
          exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
      boolean isVertical = true;
      switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
          isVertical = false;
          CurrentAngle = 270;
          break;
        case ExifInterface.ORIENTATION_ROTATE_90:
          isVertical = false;
          CurrentAngle = 90;
          break;
        case ExifInterface.ORIENTATION_ROTATE_180:
          CurrentAngle = 180;
          break;
      }
      response.putBoolean("isVertical", isVertical);
    } catch (IOException e) {
      e.printStackTrace();
      response.putString("error", e.getMessage());
      mCallback.invoke(response);
      return;
    }

    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    Bitmap photo = BitmapFactory.decodeFile(realPath, options);
    int initialWidth = options.outWidth;
    int initialHeight = options.outHeight;

    // don't create a new file if contraint are respected
    if (((initialWidth < maxWidth && maxWidth > 0) || maxWidth == 0)
        && ((initialHeight < maxHeight && maxHeight > 0) || maxHeight == 0)
        && quality == 100
        && (!forceAngle || (forceAngle && CurrentAngle == angle))) {
      response.putInt("width", initialWidth);
      response.putInt("height", initialHeight);
    } else {
      File resized = getResizedImage(getRealPathFromURI(uri), initialWidth, initialHeight);
      realPath = resized.getAbsolutePath();
      uri = Uri.fromFile(resized);
      photo = BitmapFactory.decodeFile(realPath, options);
      response.putInt("width", options.outWidth);
      response.putInt("height", options.outHeight);
    }

    response.putString("uri", uri.toString());
    response.putString("path", realPath);

    if (!noData) {
      response.putString("data", getBase64StringFromFile(realPath));
    }

    if (assetProperties) {
      WritableNativeMap assetPropertiesMap = new WritableNativeMap();

      if (options.outMimeType != null) {
        assetPropertiesMap.putString("mimeType", options.outMimeType);
      }

      String[] splitPath = realPath.split("/");
      if (splitPath.length > 0) {
        assetPropertiesMap.putString("fileName", splitPath[splitPath.length - 1]);
      }

      File file = new File(realPath);
      if (file != null) {
        assetPropertiesMap.putDouble("fileSize", file.length());
      }

      response.putMap("assetProperties", assetPropertiesMap);
      mCallback.invoke(response);
    } else {
      mCallback.invoke(response);
    }
  }