我正在尝试使用MediaPlugin(https://github.com/jamesmontemagno/MediaPlugin)拍照并将其发送到服务器。但是,当切换到相机时,android会杀死我的应用程序,拍照后,android返回操作系统的开始屏幕(带有时钟),并且没有将控制权交还给我的活动,有什么办法可以防止这种情况发生。 / p>
这是我的方法
async void OnCameraClicked(object sender, EventArgs e)
{
await Plugin.Media.CrossMedia.Current.Initialize();
var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions()
{
//SaveToAlbum = true,
CompressionQuality = 92,
PhotoSize = PhotoSize.Medium,
});
if (photo != null)
{
var expenseReg = (Expenses)BindingContext;
using (var memoryStream = new MemoryStream())
{
photo.GetStream().CopyTo(memoryStream);
expenseReg.Photo = memoryStream.ToArray();
//optional, display the photo
Photo.Source = ImageSource.FromStream(() => { return photo.GetStream(); });
photo.Dispose();
}
Photo.IsVisible = true;
}
}