Android Whatsapp上的图像共享不起作用

Android Whatsapp上的图像共享不起作用,android,share,whatsapp,whatsapi,Android,Share,Whatsapp,Whatsapi,我想将我的应用程序中的图像共享到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();

我想将我的应用程序中的图像共享到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..."));

我使用的是我网站上的图像url。

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

Uri pictureUri = Uri.parse("http://www.punjabidharti.com/wp-content/uploads/2018/05/baap-600x600.jpg");

检查一下图片,我认为它是无效的