拍下照片后,我收到Intent data
,我正在检索Uri
:
Uri contentURI = data.getData();
内容Uri为content://media/external/images/media/5576
使用此contentURI
我需要将文件保存到SD卡,请提供建议。非常感谢您的帮助。
答案 0 :(得分:0)
使用Intent
从相机拍摄照片时,为什么不将照片保存到文件夹?这会加速一些事情。试试这段代码,例如:
Intent getCameraImage = new Intent("android.media.action.IMAGE_CAPTURE");
File cameraFolder;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED))
cameraFolder = new File(android.os.Environment.getExternalStorageDirectory(),"CHANGE_TO_YOUR_FOLDER_NAME/camera");
else
cameraFolder= StatusUpdate.this.getCacheDir();
if(!cameraFolder.exists())
cameraFolder.mkdirs();
File photo = new File(Environment.getExternalStorageDirectory(), "CHANGE_TO_YOUR_FOLDER_NAME/camera/camera_snap.jpg");
getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
Uri initialURI = Uri.fromFile(photo);
startActivityForResult(getCameraImage, 2);