一个疑问。 如何共享屏幕上显示的 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/