Repository navigation
ServiceAttribute is missing foregroundServiceType #3712
Description
Activity
Workaround right now is to remove
[Service]from your service and add it manually to the AndroidManifest.Reacted by Trevor BalcomHi @Cheesebaron can you please provide a project that repros it?
thanks,
Gustavo.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.Thank you @Cheesebaron
I will take a look on it.Gustavo.
How would I declare manually for a Xamarin forms project ? , is there an ETA for this being added ?
@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.@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
Add the
[Register("com.abc.testapp.TimestampService")]on your Service.@Cheesebaron thanks, worked a treat wasn't aware of that one.
- added a commit that references this issue
on Dec 17, 2019 - added a commit that references this issue
on Dec 18, 2019 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.
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.)
Reacted by Tomasz CieleckiRelease 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/.)
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
- ghost locked as resolved and limited conversation to collaborators
on Jun 5, 2022
Android API 29 introduced
foregroundServiceTypeon 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
[Service]to your Service class.Expected Behavior
I would expect
ForegroundServiceTypeand some kind of enum would be available whenTargetFrameworkVersionis set to v10.0 in the csprojActual Behavior
No ForegroundServiceType is available
Version Information
Visual Studio Community 2019 for Mac
Version 8.3 (build 1805)
Xamarin.Android
Version: 10.0.0.43 (Visual Studio Community)
Commit: xamarin-android/d16-3/8af1ca8
Android SDK: /Users/cheesebaron/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.4
SDK Build Tools Version: 29.0.0