此相机是否将文件保存到imageUri?我从这里开始使用此代码:How to take a photo, save it and get the photo in Android
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
"fname_" + String.valueOf(System.currentTimeMillis()) + ".jpg"));
intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_REQUEST);
在onActivityResult()... 中
else if ((requestCode == CAMERA_REQUEST) && (resultcode == -1)) {
Uri selectedImage = imageUri;
mProfilePicPath = selectedImage.toString();
mPortraitPhoto = ih.decodeSampledBitmapFromImagePath(mProfilePicPath,
GlobalConstants.PROFILE_PICTURE_RESOLUTION,
GlobalConstants.PROFILE_PICTURE_RESOLUTION);
mProfilePicPath不是有效的文件路径(找不到)。
答案 0 :(得分:3)
为了获得图像的路径,您需要使用另一种Uri方法:
mProfilePicPath = selectedImage.getPath();