-
Below is my code for picking an Image from the gallery and displaying it in UI Image.
In this, I asked for user permission at the start If I grant permission this works fine. But If I select Don't Allow for the first time and call the SelectPhotoFromGallery() method the prompt for user permission is displayed. When I again select Don't Allow the prompt is hidden but after that, my app crashes after a short delay. After that whenever I open the app and try to select the image by calling this SelectPhotoFromGallery() method it crashes. Below is the Android Logcat screenshot when the app crashes. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I'm suspecting that synchronous RequestPermission inside GetImageFromGallery is causing this issue. Can you replace your code as follows and try again: public async void SelectPhotoFromGallery()
{
// Ask permission asynchronously
if (await NativeGallery.RequestPermissionAsync(NativeGallery.PermissionType.Read,NativeGallery.MediaType.Image) != NativeGallery.Permission.Granted)
return;
NativeGallery.GetImageFromGallery((path) =>
{
...
});
} |
Beta Was this translation helpful? Give feedback.
-
I was able to find out with the help of ChatGTP that an IL2CCP build works instead of Mono: Here is part of the answer: 🔎 Why IL2CPP helps:
Therefore: Translated with DeepL.com (free version) |
Beta Was this translation helpful? Give feedback.
I'm suspecting that synchronous RequestPermission inside GetImageFromGallery is causing this issue. Can you replace your code as follows and try again: