I want to add a photo from the gallery using picasso to imageView, but it is not displayed, photos from the Internet are displayed and those that were photographed from the camera are not
enter code here
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IMAGE_PICK_GALLERY_CODE && resultCode == RESULT_OK && data != null && data.getData() != null) {
image_uri = data.getData();
Picasso.with(this)
.load(image_uri)
.error(R.drawable.defaultimage)
.into(new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
image.setImageBitmap(bitmap);
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
image.setImageDrawable(errorDrawable);
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
}
});
} else {
//startActivity(new Intent(Main2Activity.this, MyActivity.class));
}
}
In High API level devices. you need to add this line in Manifest Application tag
android:requestLegacyExternalStorage="true"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.