问题描述
我如何拍照,并将其保存到特定的文件夹。我知道它保存到SD卡/ DCIM的/ etc
How do I take a photo and save it to a specific folder. I know it saves to the sdcard/DCIM/etc
但我不希望它在那里,我希望它被存储在一个文件夹中/ SD卡/相机
But I don't want it there, I want it to be stored in a folder in /sdcard/Camera
我已用下面的目录:
String destPath = Android.OS.Environment.ExternalStorageDirectory + "/Camera";
然后我启动相机的意图,并尝试点的文件保存到我所做的路径。
Then I launch the camera intent and try point the save file to the path I made.
Intent launchCamera = new Intent(Android.Provider.MediaStore.ActionImageCapture);
launchCamera.PutExtra(MediaStore.ExtraOutput, destPath);
这是行不通的。图片仍然可以保存到/ SD卡/ DCIM的/ etc
This isn't working. Images still get saved to /sdcard/dcim/etc
想法?
推荐答案
从我收集的,当我使用开发的MonoDroid的应用程序是一个摄像头是非常错误,你想让它的大部分时间是什么没有做。这包括指定的地方拍摄的图像要保存目的地。
据我所知,这些问题并不是专门针对MonoDroid的,并与Java Android SDK中确实发生。
From what I gathered when I developed an application using Monodroid is that the camera is very buggy and does not do what you want it to most of the time. This includes specifying the destination where images capture are to be saved.To my knowledge these issues aren't specific to Monodroid and do occur with the java android sdk.
一个解决这个问题,你可能想看看是拍摄图像,而无需指定目的地,然后在的onActivityResult方法来检索保存到画廊的最新图像。一旦你获得了最新的图像然后你可以将它移动到你的preferred目的地。
A work around to this issue that you may want to look at is capturing the image without specifying a destination, then in the OnActivityResult method retrieve the latest image saved to the gallery. Once you get the latest image you can then move it to your preferred destination.
下面是一些例子code从内部的onActivityResult。
Here is some example code from within OnActivityResult.
检索所捕获的图像的文件名
Retrieve the filename of the captured image
Android.Net.Uri targetUri = data.Data;
String origin = "";
String [] proj = { MediaStore.MediaColumns.Data.ToString (), BaseColumns.Id };
var qry = ManagedQuery (MediaStore.Images.Media.ExternalContentUri, proj, null, null, "date_added DESC");
qry.MoveToFirst ();
origin = qry.GetString (qry.GetColumnIndexOrThrow (MediaStore.MediaColumns.Data.ToString ()));
移动图像到你想要的目的地。
Move the image to your desired destination
System.IO.File.Move (origin, "yourdestinationfilenamehere");
这篇关于MonoDroid的设置ImageView的图像存储在SD卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!