【问题标题】:Xamarin forms How to pick a Image from GalleryXamarin 表单如何从图库中选择图像
【发布时间】:2021-05-15 06:03:19
【问题描述】:

我创建了一个简单的应用程序,我需要在内部图库中选择一张图片才能上传。我尝试使用 XAm.plugin.media nuget 但它不起作用,它给出了错误存储权限。在Android Manifest中,没有设置访问内部存储的字段它只有外部存储如何在Xamarin表单中访问内部图像

【问题讨论】:

标签: c# xamarin.forms


【解决方案1】:

在Android项目中,打开Properties文件夹下的AssemblyInfo.cs文件,添加:

// Needed for Picking photo/video
[assembly: UsesPermission(Android.Manifest.Permission.ReadExternalStorage)]

// Needed for Taking photo/video
[assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
[assembly: UsesPermission(Android.Manifest.Permission.Camera)]

// Add these properties if you would like to filter out devices that do not have cameras, or set to false to make them optional
[assembly: UsesFeature("android.hardware.camera", Required = true)]
[assembly: UsesFeature("android.hardware.camera.autofocus", Required = true)]

来源:https://docs.microsoft.com/en-us/xamarin/essentials/media-picker?tabs=android

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    • 2020-12-21
    相关资源
    最近更新 更多