我正在截取屏幕截图并使用我的应用程序名称将其保存在存储器中。它没有给出任何错误并将照片保存在存储器中,但重新启动手机后它会出现在图库中。将图像保存到图库中
我保存照片的方法是象下面这样:
public void saveQuoteImage(Bitmap quoteImage){
Date now = new Date();
android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);
try {
// image naming and path to include sd card appending name you choose for file
String dirPath=Environment.getExternalStorageDirectory().toString()+File.separator+"quotes_king";
File dirFile=new File(dirPath);
if(!dirFile.exists())dirFile.mkdirs();
// String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";
// create bitmap screen capture
File imageFile = new File(dirFile.getPath()+File.separator+ now + ".jpg");
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
quoteImage.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
// Several error may come out with file handling or OOM
e.printStackTrace();
}
}
我很想念在这?
谢谢
什么是错误? –
@victorsosa感谢您的评论。它没有给出任何错误,但只有重新启动手机后才显示保存的图像。 –