KEMBAR78
Requesting permissions using RequestAsync while the app is in the background always returns granted. · Issue #30678 · dotnet/maui · GitHub
Skip to content

Requesting permissions using RequestAsync while the app is in the background always returns granted. #30678

@AdamT04

Description

@AdamT04

Description

I'm not sure if this is expected behavior or if it's already been reported, but requesting permissions while the app is in the background consistently returns PermissionStatus.Granted, even when the permission has actually been denied. This can lead to crashes if the app then tries to use that permission.

I've created a simple test project that demonstrates the issue. It uses a button to start a timer in the MainPage's view model. The timer checks the Bluetooth permission every five seconds.

Steps to reproduce from the test project:

Deny the Bluetooth permission for the app in the device settings.
Press the "Start timer" button.
Send the app to the background.
Watch the output in the debug console.

Steps to Reproduce

1.Launch the MAUI application on a Android device/emulator.

2.Request the permission and ensure that the permission has been denied by the user.

2.Minimize the app to make it run in the background

3.While the app is in the background, programmatically request a permission (I used Permissions.Bluetooth).

4.Observe the result returned from the permission request.

Expected outcome:

The permission request should return Denied to reflect the current permission state.

Actual behavior:

The permission request returns Granted even though the permission has actually been denied.

If the app proceeds to use that permission it can lead to crashes.

Link to public reproduction project repository

https://github.com/AdamT04/TestBackgroundActivity

Version with bug

9.0.30 SR3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 14

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions