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

Do not stop service if task removed : #1783 #1784

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

brvier
Copy link
Contributor

@brvier brvier commented Apr 5, 2019

Comment the stopSelf(); in onTaskRemoved.

@AndreMiras
Copy link
Member

Thanks @brvier for the pull request. Could you elaborate why this is needed?
This was introduced in #1374 for a specific reason described in the PR and in the method comment.
Why do you think it's not needed?
Also why just commenting it rather than deleting? Last if we end up adopting that change (still have to test it), we also want to update the method documentation

@brvier
Copy link
Contributor Author

brvier commented Apr 7, 2019

Why commenting it ? Bad habits.

I don't understand why you want killing service and testing it when app is closed.

One example, if you have a Bluetooth connection in your service, you lost it, need to rescan, which could not be done at any moment in a background service, especially on some devices which prevent Bluetooth scan in background.

All other background service do the same. I'll found other example and try to understand why this was introduced in #1374

@AndreMiras
Copy link
Member

Stopping the service explicitly was a workaround to have it start again automatically when the app is killed actually. This is working in conjonction of setAutoRestartService() introduced in #643 and #1374

@inclement inclement changed the base branch from master to develop June 6, 2019 20:40
@ghost
Copy link

ghost commented Jul 28, 2019

I don't understand why you want killing service and testing it when app is closed.

From my own tests if the system kills the app at any point to preserve battery the service will actually continue to run. From this it appears that this service stop only happens if the user explicitly stops the app either via some integrated button calling sys.exit() (if you add any), or via recent apps wipe to get rid of it. The main purpose of a service to survive Android's auto-cleanup and keep vital functionality running appears to be preserved.

And isn't it kind of expected that everything stops when the user shuts down the app explicitly? Can you elaborate why you would want to not have that happen?

@brvier
Copy link
Contributor Author

brvier commented Aug 2, 2019

And isn't it kind of expected that everything stops when the user shuts down the app explicitly? Can you elaborate why you would want to not have that happen?

Not exactly, you should close user interface, but you should also keep background service communicating with external device working. There are many example of service running in background while user kill the app but it s mandatory to keep a permanent notification :

  • Audio Apps : AntennaPods (A podcast player), Spotify
  • Event based apps : KDE Connect, Syncthings, IFTTT
  • App communicating with device in real time : Mi Fit (Xiaomi Mi Band), GadgetBridge (for pebble),

There are many examples :)

@bitnom
Copy link

bitnom commented Oct 24, 2019

In our app, we are trying to have a service that runs in the background regardless of user interaction. Can we get this merged?

Copy link

@bitnom bitnom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful

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.

3 participants