![](/img/trans.png)
[英]How to share image intent to other apps(share image in apps like whatsApp and other apps)?
[英]Share image with other apps
这是我的问题......我想分享一个png图像。 我有可绘制和资产的图像。 当我使用sharingIntent它工作但不是我想要的方式。 共享的文件显示为数字而没有扩展名,一些应用程序发送消息“未知文件”。 我能做什么??
这是我的代码:
Uri uri = Uri.parse("android.resource://com.example.shareimages/" + R.drawable.caja);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(shareIntent, "send"));
我尝试使用而不是可绘制文件,资产中的文件(使用此文件:/// android_asset / ... )但它不起作用
尝试这样的事情:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.setType("image/*");
// For a file in shared storage. For data in private storage, use a ContentProvider.
Uri uri = Uri.fromFile(getFileStreamPath(pathToImage));
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(shareIntent)
如果要通过assets文件夹共享它,则必须使用ContentProvider。 请参阅此答案,了解如何执行此操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.