java - 如何共享屏幕上显示的 ImageView ?

标签 java android share

一个疑问。 如何共享屏幕上显示的 ImageView ?

这是一个应用程序示例: http://www.mediafire.com/convkey/d5a3/l0b5eobtpdbeoenzg.jpg

每次在图像上单击新图像时,所使用的资源都是一个数组,用于在 Drawable 文件夹中查找 ID。

谢谢!!!

最佳答案

Try this...Don't forget to give write storage permission in manifest 
and run time for API greater than marshmallow.
Bitmap bitmap= 
BitmapFactory.decodeResource(getResources(),R.drawable.xxxx);
String path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES)+"/LatestShare.jpg";
OutputStream out = null;
File file=new File(path);
try {
out = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
path=file.getPath();
Uri bmpUri = Uri.parse("file://"+path);
 Intent shareIntent = new Intent();
shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
shareIntent.setType("image/jpg");
startActivity(Intent.createChooser(shareIntent,"Share with"));

关于java - 如何共享屏幕上显示的 ImageView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43878568/

相关文章:

android单击一次下载两个文件并在单个进度条中分享他们的进度

java - 如何获取道路的宽度

java - 算法:将 y 个球放入 x 个盒子中,其中 x <= y

java - $bin/hadoop namenode --格式错误

android - "Android java.lang.NoClassDefFoundError: org.jsoup.Jsoup"将jar添加到/libs不起作用?

android - 丢弃对OpenGL中的程序性能有害吗?

php - Google+ 分享链接不显示说明?

java - 无法在 Spring Boot 中为每个测试方法初始化数据库

android - 关于 Android 中高性能绘图的提示

javascript - 在 Facebook 上共享动态(javascript 生成的)页面