大家好,我正在使用相机应用程序形成我的活动。使用下面的这一行,我试图将图像输出到我在 sd 卡上的指定位置。它不会将图像保存到从 getImageUri() 获取的位置,而是将文件保存到相机画廊。任何想法出了什么问题。
intent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUri());
//my getImageUri
private Uri getImageUri() {
// Store image on sdcard
String dir= Environment.getExternalStorageDirectory() +"/my_app/Datapics";
File dirs = new File(dir);
if (!dirs.exists()) {
dirs.mkdirs();
}
Bundle extras = getIntent().getExtras();
CAPTURE_TITLE = extras.getString(some.NAME);
//EDIT if i add this line here
CAPTURE_TITLE= "whatever.png";
//it will save my picture to the folder i want it to save to but with name
//whatever.png i'm getting my name from my previous activity and want
//to assign it to capture title
File file = new File(dir , CAPTURE_TITLE+".jpg");
Uri imgUri = Uri.fromFile(file);
Log.e("get imageuri called: ",imgUri.toString());
//this is what I get from here
//04-28 19:42:33.835: E/get imageuri called:(2049):
//file:///mnt/sdcard/my_app/Datapics/BlackbirdSat%20Apr%2028%2019%3A42.jpg
Log.e("get imageuri called2: ",file.toString());
//this is what i get here
//04-28 19:42:33.835: E/get imageuri called2:(2049)
//:/mnt/sdcard/my_app/Datapics/BlackbirdSat Apr 28 19:42.jpg
return imgUri;
}