carlfranklin / MAUIAndroidFS

45 stars 9 forks source link

Not working with .Net 8.0 #4

Open damusthe opened 1 month ago

damusthe commented 1 month ago

When targeting .Net 8.0, this exception is raised when calling StartForeground(myId, notification.Build()); Exception : Android.App.MissingForegroundServiceTypeException Message=Starting FGS without a type callerApp=

Clues : https://developer.android.com/about/versions/14/changes/fgs-types-required#permission-for-fgs-type

Thank you for your excellent project Carl.

damusthe commented 1 month ago

I found that putting a tag in the service attribute solve the problem :

[Service(ForegroundServiceType = global::Android.Content.PM.ForegroundService.TypeLocation)]
internal class MyBackgroundService : Service

Thanks to this link : https://stackoverflow.com/questions/77520968/why-am-i-encountering-the-error-starting-fgs-without-a-type-when-executing-the