0

我想将图像从我的应用程序共享到 Whatsapp,但它给了我错误“共享失败,请重试”这是我的代码:

String text = "Look at my awesome picture";
        Uri pictureUri = Uri.parse("file://www.punjabidharti.com/wp-content/uploads/2018/05/baap-600x600.jpg");
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_TEXT, text);
        shareIntent.putExtra(Intent.EXTRA_STREAM, pictureUri);
        shareIntent.setType("image/*");
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(Intent.createChooser(shareIntent, "Share images..."));

我正在使用我网站上的图片网址。

4

1 回答 1

0

您传递的是 http url 而不是文件 url。让你的uri像这样,它会起作用

Uri pictureUri = Uri.parse("http://www.punjabidharti.com/wp-content/uploads/2018/05/baap-600x600.jpg");
于 2018-05-20T19:45:01.883 回答