【问题标题】:ImagePath doesn't always workImagePath 并不总是有效
【发布时间】:2015-04-16 01:49:14
【问题描述】:

我已经为此苦苦挣扎了一整天 :-( 我目前的方法看起来像这样

File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/image.jpg");
imagePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/image.jpg";
startActivityForResult(IntentUtils.dispatchTakePictureIntent(getActivity(), file), REQUEST_IMAGE_CAPTURE);

之后我做了一些不重要的事情来正确显示位图,然后用这个方法显示它

placeImageView.setImageBitmap(rotatedBitmap);

*EDIT 这就是我创建意图的方式

 Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(context.getPackageManager()) != null) {

        if (file != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(file));
            return takePictureIntent;
        }
    }
    return null;
}

到目前为止有效。

但是当我在下一个活动中使用这个imagePath 时,位图不会加载。我之前已经用这个文件路径尝试了很多东西,现在我只是对所有可能的处理方法感到不知所措......

【问题讨论】:

  • 您遇到什么错误?您是否在第二个活动中定义 imagePath?
  • 发布你如何在“nextactivity”中加载位图?
  • 好吧我的错误是不同的,我得到了一个空指针,因为我没有图像视图的尺寸并试图用它做一些计算

标签: android android-camera android-camera-intent android-bitmap


【解决方案1】:

这听起来可能微不足道,但您已经检查了图像是否真的被记录在您想要的位置 - 即您是否使用标准手机文件资源管理器检查了图像? (我会将此作为评论发布,但我的声誉太低了。)

【讨论】:

    猜你喜欢
    • 2012-12-26
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2015-06-28
    • 2015-12-04
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多