Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: specify foreground service type for API level >=29 #2951

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benma
Copy link
Contributor

@benma benma commented Oct 2, 2024

https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)

Note: Beginning with SDK Version
Build.VERSION_CODES.UPSIDE_DOWN_CAKE, apps targeting SDK Version Build.VERSION_CODES.UPSIDE_DOWN_CAKE or higher are not allowed to start foreground services without specifying a valid foreground service type in the manifest attribute
R.attr.foregroundServiceType. See Behavior changes: Apps targeting Android 14 for more details.

In the simulator for Android 34 the app seems to work without this change.

https://developer.android.com/reference/android/app/Service#startForeground(int,%20android.app.Notification)

> Note: Beginning with SDK Version
Build.VERSION_CODES.UPSIDE_DOWN_CAKE, apps targeting SDK Version
Build.VERSION_CODES.UPSIDE_DOWN_CAKE or higher are not allowed to
start foreground services without specifying a valid foreground
service type in the manifest attribute
R.attr.foregroundServiceType. See Behavior changes: Apps targeting
Android 14 for more details.

In the simulator for Android 34 the app seems to work without this
change.
@benma
Copy link
Contributor Author

benma commented Oct 2, 2024

The AndroidManifest only specifies dataSync, so maybe on Android 34, the deviceConnected one is not actually in use? With this commit, on Android 34 both types would be specified in the code call, which takes precedence over the manifest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant