Error when starting background service on Android 14 #21217
Unanswered
ggbarcelos
asked this question in
Q&A
Replies: 1 comment
-
I don't think this is a bug in .NET MAUI. If anything this would be a .NET for Android bug, but right now I don't have any reason to think this is a bug to begin with but something that is not setup correctly in your project. As such, converting this to a discussion. I am using this similar setup for my ScreenRecording plugin maybe there is a hint in there on something that you are still missing. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I am trying to start a background service on Android 14 using the following code:
**if (Build.VERSION.SdkInt >= BuildVersionCodes.Q)
{
StartForeground(Constants.SERVICE_RUNNING_NOTIFICATION_ID, RegisterForegroundService(GetString(Resource.String.foregroundSemChamado), true), ForegroundService.TypeMediaPlayback);
}
else
{
StartForeground(Constants.SERVICE_RUNNING_NOTIFICATION_ID, RegisterForegroundService(GetString(Resource.String.foregroundSemChamado), true));
}
**
However, I am receiving the following error:
**Java.Lang.SecurityException: 'Starting FGS with type mediaPlayback callerApp=ProcessRecord{ccb3c8f 10781:br.trueit.pythagoras/u0a409} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK] '
**
I made the correct declarations both in the AndroidManifest and by explicitly asking for permissions at runtime. Still, I am facing this problem. Any help to solve this would be greatly appreciated.
My AndroidManifest:
Inside
<application>
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.7 SR2
Affected platforms
Android
Affected platform versions
Android 14
Did you find any workaround?
No response
Relevant log output
No response
Beta Was this translation helpful? Give feedback.
All reactions