Xamarin 用户如何获取所选图像的流(BitmapFactory.DecodeStream(inputStream)返回null)

Xamarin 用户如何获取所选图像的流(BitmapFactory.DecodeStream(inputStream)返回null),xamarin,xamarin.forms,xamarin.android,Xamarin,Xamarin.forms,Xamarin.android,加载用户的选定图像并将流传递到BitmapFactory.DecodeStream(inputStream)时,我总是得到结果null 我像这样加载图像流: Stream=new Java.Net.URL(Uri.Parse($“file://{imageFile.Path}”).ToString()).OpenStream()我还尝试了许多其他变体,如: BitmapFactory.DecodeStream(Activity.ContentResolver.OpenInputStream(ur

加载用户的选定图像并将流传递到
BitmapFactory.DecodeStream(inputStream)
时,我总是得到结果
null

我像这样加载图像流:

Stream=new Java.Net.URL(Uri.Parse($“file://{imageFile.Path}”).ToString()).OpenStream()我还尝试了许多其他变体,如:

BitmapFactory.DecodeStream(Activity.ContentResolver.OpenInputStream(uri)
new Java.IO.FileInputStream(imageFile.Path)

我拥有
WriteExternalStorage
的权限。是什么导致了问题?如何解决


此处提供了示例项目

您可能需要使用内容解析程序。不幸的是,整个过程在sdk版本之间不一致,有时甚至在设备之间也不一致。请看一下media picker插件如何处理文件的获取。实际上,我已经将其GetFileForUriAsync方法复制/粘贴到了我的项目中