I have an app that shares images from url. Last android update, I got message from instagram "Unable to load image" when I want to share an image in instagram feed.
But i can share image story, direct message, and everywhere... I am having this issue only instagram feed.
public void onShareItemOreo() {
// Get access to bitmap image from view
imageView = (ImageView) findViewById(R.id.thumbnail);
// Get access to the URI for the bitmap
Uri bmpUri = prepareShareIntent(imageView);
if (bmpUri != null) {
//outfile is the path of the image stored in the gallery
// Construct a ShareIntent with link to image
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setData(bmpUri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT,marketLink);
// Launch sharing dialog for image
startActivity(Intent.createChooser(shareIntent, "Share Image"));
} else {
//
}
}
public Uri prepareShareIntent(ImageView imageView) {
// Fetch Bitmap Uri locally
Drawable drawable = imageView.getDrawable();
Bitmap bmp = null;
if (drawable instanceof BitmapDrawable){
bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
} else {
return null;
}
Uri bmpUri = getBitmapFromDrawable(bmp);// see previous remote images section and notes for API > 23
// Construct share intent as described above based on bitmap
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setType("image/*");
return bmpUri;
}