0
我有Click方法將圖像保存到圖庫中。之後我點擊「保存」的文件夾中創建的畫廊,但是當我去到畫廊它說:「沒有縮略圖」 ... 這裏是我的代碼:它表示圖像保存到圖庫後的「無縮略圖」 - android位圖
String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
File myDir = new File(root + "/PhotoEditor ");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-" + n + ".jpg";
File file = new File(myDir, fname);
if (file.exists())
file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
if (sb != null) {
sb.compress(Bitmap.CompressFormat.JPEG, 90, out);
}
out.flush();
out.close();
}
catch (Exception e) {
e.printStackTrace();
}
Toast.makeText(ShowPhotoActivity.this,"Your image is saved to gallery",Toast.LENGTH_LONG).show();
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(ShowPhotoActivity.this, new String[] { file.toString() }, null,
new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
}
});
是的,我認爲它沒有得到位圖。你能告訴我一個代碼什麼的嗎? –