使用操作的Andr​​oid应用程序分享的图像发送意图它不工作:(它不、意图、应用程序、图像

2023-09-05 10:59:22 作者:九五之尊.

我是用

Intent sharingIntent = new Intent(Intent.ACTION_SEND);

Uri screenshotUri = Uri.parse("file//res/drawable/u.png");
 

sharingIntent.setType("image/png");


sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);


startActivity(Intent.createChooser(sharingIntent, "Share image using"));

//我用三星真正的device.and我选择Facebook分享。 //但是内容是空的不是我的图像共享我不能共享图像。

//I use sumsung real for device.and i choose share on facebook. //But content is empty not my image to shared i can't shared image.

这是故意的动作发送不使用Facebook SDK。 你能帮助我吗?

This is intent action send isn't use facebook sdk. can you help me please?

推荐答案

您打算错误的方式来访问文件夹可绘制对象使用这种方式。

You are going to wrong way to Access Drawable folder use this Way.

Uri imageUri = Uri.parse("android.resource://your.package/drawable/fileName");

您应该尝试这种方式:

      Uri imageUri = Uri.parse("android.resource://your.package/drawable/fileName");
      Intent intent = new Intent(Intent.ACTION_SEND);
      intent.setType("image/png");

      intent.putExtra(Intent.EXTRA_STREAM, imageUri);
      startActivity(Intent.createChooser(intent , "Share"));