Android保存图像两次
我正在用编程的方式为我的几张照片做一个截图,但不知怎么的,图像保存在/TestProject/文件夹中,但也保存在普通图片文件夹中。有人知道为什么会这样吗。(安卓的普通图片文件夹会同时显示所有图片吗?)Android保存图像两次,android,Android,我正在用编程的方式为我的几张照片做一个截图,但不知怎么的,图像保存在/TestProject/文件夹中,但也保存在普通图片文件夹中。有人知道为什么会这样吗。(安卓的普通图片文件夹会同时显示所有图片吗?) insertImage()方法还为插入的图像创建缩略图。您很可能看到缩略图和插入的图像 如果要通过媒体存储强制扫描图像,则应改用scanFile()[0]方法 [0] OutputStream out; root.setDrawingCacheEnabled(true); Bi
insertImage()
方法还为插入的图像创建缩略图。您很可能看到缩略图和插入的图像
如果要通过媒体存储强制扫描图像,则应改用scanFile()
[0]方法
[0]
OutputStream out;
root.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(root.getDrawingCache());
root.setDrawingCacheEnabled(false);
/* Preparation ==================================== */
// Find the SD Card path
File path = Environment.getExternalStorageDirectory();
// Create a new folder in SD Card
File dir = new File(path.getAbsolutePath() + "/TestProject/");
dir.mkdirs();
/* ================================================= */
// Create a name for the saved image
File file = new File(dir, (new Date().getTime() + ".jpg"));
try {
out = new FileOutputStream(file);
// Compress into png format image from 0% - 100%
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, (new Date().getTime() + ".jpg"), null);
Toast.makeText(this, "Farm art saved", Toast.LENGTH_LONG).show();
} catch (Exception e) {
e.printStackTrace();
}