Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AskForRequiredPermission always return false on samsung sm-n986w android 13.0 api 33 #13

Open
eddyjl077 opened this issue Aug 13, 2023 · 0 comments

Comments

@eddyjl077
Copy link

public static async Task AskForRequiredPermission()
{
try
{
var canRequestInstallPackage = true;
if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
canRequestInstallPackage = Platform.CurrentActivity.PackageManager.CanRequestPackageInstalls();

            if (!canRequestInstallPackage)
            {
                Platform.CurrentActivity.StartActivity(new Intent(
                    Android.Provider.Settings.ActionManageUnknownAppSources,
                    Android.Net.Uri.Parse("package:" + Android.App.Application.Context.PackageName)));
            }

            var writeStatus = await Permissions.CheckStatusAsync<Permissions.StorageWrite>();
            if (writeStatus != PermissionStatus.Granted)
            {
                **await Permissions.RequestAsync<Permissions.StorageWrite>();**
            }
            writeStatus = await Permissions.CheckStatusAsync<Permissions.StorageWrite>();

            var readStatus = await Permissions.CheckStatusAsync<Permissions.StorageRead>();
            if (readStatus != PermissionStatus.Granted)
            {
                **await Permissions.RequestAsync<Permissions.StorageRead>();**
            }

            readStatus = await Permissions.CheckStatusAsync<Permissions.StorageRead>();

            if (writeStatus == PermissionStatus.Granted && readStatus == PermissionStatus.Granted && canRequestInstallPackage)
                return true;
        }
        catch (Exception ex)
        {
            //Something went wrong
        }
        return false;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant