我正在SD卡中保存一個位圖,之後我立即調用了Intent.ACTION_MEDIA_MOUNTED
。保存的圖像需要幾分鐘才能顯示在圖庫中
它顯示在圖庫中,但圖像顯示大約需要5分鐘。有什麼辦法讓它瞬間完成?
File newFile = new File(newFilename);
if (newFile.exists()) {
newFile.delete();
}
try {
FileOutputStream out = new FileOutputStream(newFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
Toast.makeText(context, "Photo will appear in the Gallery in a few minutes.", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
e.printStackTrace();
}