You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ServiceAttribute is missing foregroundServiceType #3712
Android API 29 introduced foregroundServiceType on Services to classify what kind of service it is. Kind of like on iOS, for background downloads, music etc.
This attribute is needed in the AndroidManifest.xml when targeting API 29 (Android Q), when wanting to distinguish between stuff like Foreground Location updates and Background Location updates.
Steps to Reproduce
Add [Service] to your Service class.
Explore the properties exposed
Expected Behavior
I would expect ForegroundServiceType and some kind of enum would be available when TargetFrameworkVersion is set to v10.0 in the csproj
Actual Behavior
No ForegroundServiceType is available
Version Information
Visual Studio Community 2019 for Mac
Version 8.3 (build 1805)
@chrisfoulds remove the [Service] attribute on your service and add the entry to your AndroidManifest.xml file yourself. See the attatched ServiceTypeTest.zip for an example.
A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
Fix included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Previewupdater channel.
A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Previewupdater channel.)
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.2.0.100.
Fix included on macOS in Visual Studio 2019 for Mac version 8.5. To get the new version that includes the fix, check for the latest updates on the Stableupdater channel.
Activity
Cheesebaron commentedon Oct 1, 2019
Workaround right now is to remove
[Service]from your service and add it manually to the AndroidManifest.gugavaro commentedon Oct 15, 2019
Hi @Cheesebaron can you please provide a project that repros it?
thanks,
Gustavo.
Cheesebaron commentedon Oct 16, 2019
ServiceTypeTest.zip
I've attached a project.
Using the
ServiceAttributeas seen onMyService, there is no way to specifyForegroundServiceTypeas that property does not exist.The workaround is to manually register the service in the manifest as seen for
MyService2.gugavaro commentedon Oct 16, 2019
Thank you @Cheesebaron
I will take a look on it.
Gustavo.
chrisfoulds commentedon Nov 12, 2019
How would I declare manually for a Xamarin forms project ? , is there an ETA for this being added ?
Cheesebaron commentedon Nov 12, 2019
@chrisfoulds remove the
[Service]attribute on your service and add the entry to your AndroidManifest.xml file yourself. See the attatched ServiceTypeTest.zip for an example.chrisfoulds commentedon Nov 12, 2019
@Cheesebaron I tried that and it didn't work which is why I asked.
I added :
<service android:name="com.abc.testapp.TimestampService" />Yet the autogenerated one using [Service] comes out as :
<service android:name="md586c6802ef9432e3426afeadf29df91ef.TimestampService" />So quite different locations
Cheesebaron commentedon Nov 12, 2019
Add the
[Register("com.abc.testapp.TimestampService")]on your Service.chrisfoulds commentedon Nov 16, 2019
@Cheesebaron thanks, worked a treat wasn't aware of that one.
[Mono.Android] Add ServiceAttribute.ForegroundServiceType (dotnet#3810)
[Mono.Android] Add ServiceAttribute.ForegroundServiceType (#3810)
brendanzagaeski commentedon Jan 23, 2020
Release status update
A new Preview version has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix.
Fix included in Xamarin.Android 10.2.0.84.
Fix included on Windows in Visual Studio 2019 version 16.5 Preview 2. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.
Fix included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.
brendanzagaeski commentedon Mar 17, 2020
Release status update
A new Release version has now been published on Windows that includes the fix for this item. The fix is not yet published in a Release version on macOS. I will update this item again when a Release version is available on macOS that includes the fix.
Fix included in Xamarin.Android 10.2.0.100.
Fix included on Windows in Visual Studio 2019 version 16.5. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.
(Fix also included on macOS in Visual Studio 2019 for Mac version 8.5 Preview 1 and higher. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.)
brendanzagaeski commentedon Mar 24, 2020
Release status update
A new Release version has now been published on macOS that includes the fix for this item.
Fix included in Xamarin.Android 10.2.0.100.
Fix included on macOS in Visual Studio 2019 for Mac version 8.5. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.
(Fix also included on Windows in Visual Studio 2019 version 16.5 and higher. To get the new version that includes the fix, check for the latest updates or install the latest version from https://visualstudio.microsoft.com/downloads/.)
unamed000 commentedon Jan 11, 2021
I'm not able to find this attribute in the latest stable version of Xamarin.Android. Anyone has any ideas?
EDIT: Nevermind, I have to exit VS again after switching to API Target 29 to be able to see that new attribute