public void openCamera() { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File imageFile = FileUtil.createImageFile(); setFilePath(imageFile.getPath()); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); ((Activity) getContext()) .startActivityForResult(cameraIntent, UserPortraitScreenlet.TAKE_PICTURE_WITH_CAMERA); }
public void upload(int requestCode, Intent onActivityResultData) { try { String picturePath = ""; if (requestCode == SELECT_IMAGE_FROM_GALLERY) { picturePath = FileUtil.getPath(getContext(), onActivityResultData.getData()); } else if (requestCode == TAKE_PICTURE_WITH_CAMERA) { picturePath = _filePath; } performUserAction(UPLOAD_PORTRAIT, picturePath); } catch (IllegalArgumentException e) { onUserPortraitUploadFailure(e); } }