我创建具有相机功能的应用程序,我调用相机,意图拍摄照片并将文件保存在外部存储“下载”文件夹中,但随后我搜索它们在另一个文件夹“/storage/emulated/0/download/”中。
为什么android需要2个导演?除了我保存的照片之外,使用相同的文件。
我正在使用 Galaxy Nexus 手机。对于 Galaxy 平板电脑,一切都很好。
public void openCamera(View view) {
try {
int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1991;
photoName();
String _path = Environment.getExternalStoragePublicDirectory(DOWNLOAD_SERVICE) + "/" + photoFileName;
System.out.println("PATH: "+ _path);
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
} catch (Exception e) {
}
private String photoName() {
boolean isWhile = true;
int randomId = 0;
int count = 0;
while (isWhile) {
photoFileName = "MobiliSkaita_" + count + ".jpg";
File fileToCheck = new File(Environment.getExternalStoragePublicDirectory(DOWNLOAD_SERVICE) + "/" + photoFileName);
if (fileToCheck.exists()) {
System.out.println("FAILAS YRA: " + randomId);
randomId++;
photoFileName="MobiliSkaita_" + randomId + ".jpg";
} else {
System.out.println("FAILAS NERA: " + randomId);
isWhile = false;
}
count++;
}
return photoFileName;