【发布时间】:2016-05-31 15:11:31
【问题描述】:
在 Nexus 和 LG G3 设备(到目前为止我已经尝试过)上,我成功地将设备内存中的图像加载到 ImageView(使用 Picasso)中,如下所示:
mProfileImageView.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), 2);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == getActivity().RESULT_OK) {
Picasso.with(getContext()).setLoggingEnabled(true);
if (requestCode == 2) {
Picasso.with(getContext())
.load(data.getData())
.noPlaceholder()
.centerCrop()
.fit()
.into(mProfileImageView);
}
}
}
但是,由于某种奇怪的原因,这在 Galaxy S4 和 S5 上不起作用。
我正在使用毕加索 2.5.2
任何善良的灵魂可以帮助我吗?
提前致谢!
【问题讨论】:
-
您选择的图片是否很大?尝试使用小图像。还要确保您使用的是最新版本的毕加索。
-
@AliSheikhpour 我正在尝试使用 19KB JPEG,但没有成功
-
您在调试器上收到任何错误吗?
-
记录器向我显示此消息两次:
E/MiniThumbFile: Unable to create .thumbnails directory /storage/emulated/0/DCIM/.thumbnails -
感谢您的帮助。正如我在回答中所说,这是一个许可问题。非常感谢!