tempuri=Uri.fromFile(getOutputFromCamera());
其中getOutputFromCamera()是
private File getOutputFromCamera() {
File storageDir = new File(
Environment
.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
AppConstants.FOLDER_NAME);
if (!storageDir.exists()) {
if (!storageDir.mkdirs()) {
Log.i(TAG, "Failed to create directory " + storageDir
+ AppConstants.FOLDER_NAME);
Toast.makeText(this, "Failed to create Directory",
Toast.LENGTH_SHORT).show();
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss",
Locale.getDefault()).format(new Date());
File imageFile = new File(storageDir.getPath() + File.separator
+ "IMG_" + timeStamp + ".png");
return imageFile;
}
凡Environment.DIRECTORY_PICTURES是默認的圖片目錄,並AppConstants.FOLDER_NAME是圖像保存文件夾名。您可以根據您的需要更改這些。