不能共享图像正常的android [英] can't share image properly android
本文介绍了不能共享图像正常的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在Gmail分享图像一次,再来做一些改变,并再次如果我再分享只有previous图像显示:(这是问题4.1.1当我运行相同4.2.2问题它完美的作品:( :(:(
您好我怎么使用意向的,我是用低于code共享图片
Hi i what to share image using Intent for that i have used below code
public void otherBtn(View v) {
FileOutputStream out = null;
try {
if (bitmap != null) {
bitmap.recycle();
bitmap = null;
}
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
File sdcard = Environment.getExternalStorageDirectory();
File f = new File(sdcard, "temp.jpg");
if (f.isFile()) {
f.delete();
}
out = new FileOutputStream(f);
captureRelativeLayout.setDrawingCacheEnabled(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(
Config.ARGB_8888, false);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); // imageUri
sharingIntent.setType("image/jpg");
startActivity(sharingIntent);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.flush();
out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
例如,当我下面高于code图像共享
for example when i share below image with above code
我有previously共享将显示,但上面没有更新图像显示图像:(
the image which i have previously shared will shown but not above updated image is showing :(
推荐答案
您冲洗并关闭后的数据流的开始活动。你需要做的之前以正确写入文件内容。
You flush and close the stream after starting the activity. You need to do it before to write the file contents properly.
out = new FileOutputStream(f);
captureRelativeLayout.setDrawingCacheEnabled(true);
bitmap = captureRelativeLayout.getDrawingCache(true).copy(
Config.ARGB_8888, false);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
// Flush and close stream
out.flush();
out.close();
// Now it's safe to use the file
sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sharingIntent.setType("image/jpg");
startActivity(sharingIntent);
这篇关于不能共享图像正常的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文