Instagram供稿中的共享意图问题

问题描述 投票:7回答:4

我有一个共享网址图片的应用。上次的android更新,当我想在instagram feed中共享图像时,我从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;
}
android image android-intent share
4个回答
0
投票

好吧,我搜索并找到了解决方案。我不知道这是正确的方法,但是解决了我的问题。

StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());

Found solution in this answer.


0
投票

您的uri是“ content://packagename/xxx.jpg”,它必须是“ content:// media / external / images / media / ...”;它将起作用。


0
投票

Facebook正在研究此错误,请等待!订阅以接收对此错误报告的更新通知。https://developers.facebook.com/support/bugs/1326888287510350/


0
投票

上述解决方案都没有对我有用,因为似乎通过ContentProvider或其派生词FileProvider进行的直接共享被Instagram应用程序中的更改所破坏。

© www.soinside.com 2019 - 2024. All rights reserved.