【发布时间】:2020-03-21 11:00:11
【问题描述】:
我有一个从 url 共享图像的应用程序。上次安卓更新,当我想在 Instagram 订阅中分享图片时,我收到了来自 Instagram 的消息“无法加载图片”。
但我可以在任何地方分享图片故事、直接消息和...我只遇到这个问题。
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;
}
【问题讨论】:
-
试试这个:share.setType("image/jpeg");
-
@AliHas i have ("image/*)
-
遇到同样的问题,有什么消息吗?
标签: android image android-intent share