我有一个问题,拍摄图像,并从原生相机应用存储它。下面是我的一些code的样本。
I am having a problem capturing an image and storing it from the native camera app. Here is a sample of some of my code.
_path = Environment.getExternalStorageDirectory() + "make_machine_example.jpg";
File file = new File( _path );
Uri outputFileUri = Uri.fromFile( file );
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );
startActivityForResult( intent, 0 );
在该照片拍摄,我返回到我原来的活动,当我浏览到通过的Android DDMS我的SD卡文件浏览器画面不存在。任何人都知道这是为什么不被保存?
After the picture has been taken and I'm returned back to my original Activity, When I navigate to my sd card via Android DDMS File Explorer the picture is not there. Anyone know why this is not being saved?
你检查什么Environment.getExternalStorageDirectory()的输出,因为如果它不包含结尾的文件分隔符(/),那么你的形象将结束在一个目录不驻留在SD卡,例如:
Have you checked what the output of Environment.getExternalStorageDirectory() is, because if it does not contain a trailing file seperator (/) then your image will end up in a directory that does not reside on the SDcard such as:
/mnt/sdcardmake_machine_example.jpg
当你真正想要的是:
/mnt/sdcard/make_machine_example.jpg
试试这个code来代替:
Try this code instead:
_path = Environment.getExternalStorageDirectory() + File.separator + "make_machine_example.jpg";