C# 在MonoDroid应用程序中拍摄2张照片后,相机应用程序停止工作
在MonoDroid应用程序中,以下代码用于启动本机相机应用程序:C# 在MonoDroid应用程序中拍摄2张照片后,相机应用程序停止工作,c#,android,xamarin.android,C#,Android,Xamarin.android,在MonoDroid应用程序中,以下代码用于启动本机相机应用程序: internal void TakePicture(int pictureId) { var uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, new ContentValues()); var intent = new Intent(MediaStore.ActionImageCap
internal void TakePicture(int pictureId)
{
var uri = ContentResolver.Insert(MediaStore.Images.Media.ExternalContentUri, new ContentValues());
var intent = new Intent(MediaStore.ActionImageCapture);
intent.PutExtra(MediaStore.ExtraOutput, uri);
StartActivityForResult(intent, ACTIVITY_RESULT_PICTURE_TAKEN);
pictureId = pictureId;
pictureUri = uri;
}
拍摄完照片后,将在此处进行处理:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (requestCode == ACTIVITY_RESULT_PICTURE_TAKEN)
{
if (resultCode == Result.Ok)
{
/* The URI is not a valid path, but something internal to Android
* See
* https://stackoverflow.com/questions/8448796/monodroid-setting-imageview-to-image-stored-on-sdcard
* for more information. */
if (OnPictureTaken != null)
OnPictureTaken(this, new PictureTakenEventArgs(pictureId, GetRealPathFromURI(pictureUri)));
}
}
}
前两次尝试拍照总是成功,但第三次失败
Android摄像头应用程序允许您拍照,但它不会关闭,也不会关闭
不再将图片返回到应用程序。。。
(上面的事件处理程序也不会被调用)
我们正在华硕Transformer 101平板电脑(多个固件版本)上测试此功能
PS:我找到了这个条目,但我认为这是另一个问题
有什么建议吗
更新:
当拍摄低分辨率照片时,问题不会出现我的变压器也有类似的问题,但我的问题是它从未工作过。我想我从来没有尝试过要求不同的图像大小。这对我很有帮助,是唐恩·费尔克的回答帮了我的忙。我必须确保在启动照相机意图之前创建了一个空文件,以便照相机应用程序允许“确定”按钮完成意图。我来看看thnx!如果有帮助的话,我会把它标记为答案