Skip to content

fix(android_intent_plus): startForegroundService on SDK higher than 26 #3533

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ViscousPot
Copy link
Contributor

@ViscousPot ViscousPot commented Mar 28, 2025

Description

Currently, when starting a foreground service or a non-foreground service while the application is in the background, the application fails with

not allowed to start service intent app is in background

This can be tested by trying to start a service where the application isn't in the foreground

  • Previous behaviour, it would give the error above
  • New behaviour sends the intent as expected and starts the service

The activity.startService logic has been removed as it isn't super necessary (applicationContext works fine) and it doesn't seem to work for startForegroundService when the target app is in the background, but I might be wrong here

Related Issues

No related issues exist for this

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@miquelbeltran
Copy link
Member

Thanks for looking into this! Could you add an example to the example that runs a foreground service? I'm trying to understand when this would be necessary, and I would like to test before approving. Also, the PR is set as Draft, not sure if that is intentional.

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.

2 participants