question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Foreground service doesn't work in Android 10

See original GitHub issue

Hi,

In Android 10 the service definition in the manifest file must have: android:foregroundServiceType="location" in order for the foreground service to work properly (ie. when user select “only while using app” as location permission.

<service android:enabled="true" android:exported="false" android:foregroundServiceType="location" android:name="com.marianhello.bgloc.service.LocationServiceImpl" />

I hope it is possible to add this in the next version.

Does anyone have a quick fix for this? My current solution is to add the line manually to the manifest file after each “cordova prepare”. It is just a matter of time before I forget it before releasing.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:13

github_iconTop GitHub Comments

3reactions
mobilemarinescommented, Feb 8, 2021

To be honest, this (discontinued) plugin and all (I guess - don’t know all) forks are dying due to the lack of adjustments to the latest SDKs and other evolution. There have been a lot of changes in Android 10 + 11 regarding the background (always) permission and capability of sending position updates in the background. Also iOS 14 introduced the approximate location. Additionally many major vendors kill apps in the background, see https://dontkillmyapp.com/ So this plugin should actually be renamed to cordova-plugin-foreground-geolocation. 😉 Only the original (paid) plugin seems to keep track of the plugin to work in the background/minimized: https://github.com/transistorsoft/cordova-background-geolocation-lt

2reactions
isinocasiocommented, Feb 8, 2021

To be honest, this (discontinued) plugin and all (I guess - don’t know all) forks are dying due to the lack of adjustments to the latest SDKs and other evolution. There have been a lot of changes in Android 10 + 11 regarding the background (always) permission and capability of sending position updates in the background. Also iOS 14 introduced the approximate location. Additionally many major vendors kill apps in the background, see https://dontkillmyapp.com/ So this plugin should actually be renamed to cordova-plugin-foreground-geolocation. 😉 Only the original (paid) plugin seems to keep track of the plugin to work in the background/minimized: https://github.com/transistorsoft/cordova-background-geolocation-lt

That is true, actually Im starting to train myself in Flutter because all of this issues with cordova.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Foreground services - Android Developers
Foreground services perform operations that are noticeable to the user. Foreground services show a status bar notification, so that users are actively aware ......
Read more >
App not sending location from Foreground service on Android ...
I have a foreground service sending location updates. The app stops sending locations when the following conditions are met: Running on Android ......
Read more >
The “misbehaving” foreground service in Android
Foreground services ​​ According to the official android documentation, a foreground service performs operations that are noticeable to the user. ...
Read more >
Auto-Start Foreground Service in Android - Medium
Perfect way to run service even Android device restarted ... What is the foreground service? Now let me tell you a little bit...
Read more >
WorkManager long-running work doesn't work specifying ...
Devices/Android versions reproduced on: Pixel 4 - Android 10 ... at android.app.Service.startForeground(Service.java:742) at androidx.work.impl.foreground.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found