简体   繁体   English

Xamarin 表单如何从图库中选择图像

[英]Xamarin forms How to pick a Image from Gallery

I created a simple app I need to select an image in internal Gallery in order to upload it.我创建了一个简单的应用程序,我需要在内部图库中选择一个图像才能上传它。 I tried it with XAm.plugin.media nuget But it does not work it gives error Storage pErmission.我用 XAm.plugin.media nuget 尝试过,但它不起作用,它给出了错误存储许可。 In Android Manifest, There is no field to set the access to internal storage it only has external storage How to access internal Image in Xamarin forms在Android Manifest中,没有设置访问内部存储的字段,它只有外部存储如何在Xamarin表单中访问内部图像

In the Android project, open the AssemblyInfo.cs file under the Properties folder and add:在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)]

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以 xamarin 形式从图库中选择图像? - How to select an image from gallery in xamarin forms? 将图像从图像框保存到 Xamarin Forms 中的图库 - Save image from an image box to gallery in Xamarin Forms 我们可以从手机(Android / iOS)中选择一个图像并使用公共代码(Xamarin Forms)将其上传到服务器吗? - Can we pick a Image from Phone (Android / iOS) and upload it to server with common code(Xamarin Forms)? 如何以 xamarin 形式将视频保存到图库 - how to save videos to the gallery in xamarin forms 如何从Xamarin Android中的图库中获取选定的图像名称 - How to get selected image name from gallery in xamarin android 如何在iOS Xamarin Studio中将图像从画廊上传到Web API 2 - How to upload image from gallery to web api 2 in ios xamarin studio 如何使用图像中的绑定标签在 xamarin 表单上显示图像 - how to display an image on xamarin forms using binding tag from image 我使用XLABS从图库中挑选图像。 如何获取图像的文件路径? - I use XLABS to pick images from a gallery. How to get the filepath of the image? Xamarin.forms 如何添加拍照功能或从图库中选择照片 - Xamarin.forms how I can add ability to take photo or select it from Gallery 如何从 Xamarin Forms 中的图库中 select 多张图片并保存到所需的文件路径? - How to select multiple images from gallery in Xamarin Forms and save to desired file path?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM