Xamarin grant permission to read file.

Jason Tho 1 Reputation point
2021-01-19T13:10:51.147+00:00

I build a Xamarin.forms and with XlsIO . what i plan was when the app start up will check the permission was grant or not ? It work prefect and show what i wish in debug mode when PC connect to my phone but when install with signed.apk. After install it just shut down when it open , can someone let me know how to solve this problem ?? Thanks.
some information setting...
Application Target Framework --Android 10.0 Q
Android Manifest -- min Android 5.0 , max Android 9.0

READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE --done

And the code in App.xaml.cs

protected async override void OnStart()
        {
            var status = await Permissions.CheckStatusAsync<Permissions.StorageWrite>();
            if (status != PermissionStatus.Granted)
            {
                status = await Permissions.RequestAsync<Permissions.StorageWrite>();
                if (status != PermissionStatus.Granted)
                {
                    string v = $"Permission must be ALLOW acceess to searching folder";
                    await App.Current.MainPage.DisplayAlert("", v, "OK");
                    await Permissions.RequestAsync<Permissions.StorageWrite>();
                }
            }
        }

my phone with Android 10
thanks...

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,366 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JessieZhang-MSFT 7,711 Reputation points Microsoft Vendor
    2021-01-29T02:50:40.143+00:00

    Hello,

    Welcome to our Microsoft Q&A platform!

    You can first try to repair your visual studio. For more details, you can check: https://learn.microsoft.com/en-us/visualstudio/install/repair-visual-studio?view=vs-2019.

    If the problem persists,you can perform a thorough uninstall for Xamarin for Visual Studio and install it again, for more details, you can check: https://learn.microsoft.com/en-us/xamarin/cross-platform/troubleshooting/questions/uninstall-xamarin-vs .

    Hope it can help you.

    Best Regards,

    Jessie Zhang

    ---
    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.