Hacker News new | ask | show | jobs
by viraptor 3633 days ago
Well, it was a rant rather than information. And I disagree with it from the beginning:

> You should not close apps because you may interfere with tracking your location and other data collection.

That's bullshit reason - you'd write a background service, not try to stop users from closing the app. For any single application I'm using I'm happy for it to be cached rather than restarting every time. This is just arguing against a cache layer, because <made up reason>.

1 comments

Going offtopic from the rant to an Android development question, if I may - I thought background services were shut down brutally at random times, and hard to keep running reliably unless some app which uses them is open? I'm a newbie to Android dev, but I have an app which (attempts to) maintain an always-on connection, and I've gone with a foreground service because that doesn't get killed (as often).
That seems to go against the documentation: (https://developer.android.com/guide/components/services.html)

> A started service must manage its own lifecycle. That is, the system does not stop or destroy the service unless it must recover system memory and the service continues to run after onStartCommand() returns.

A started service shouldn't be killed randomly - after all, that's how the downloads are handled - you don't see those disappearing without a reason.

Downloads are generally handled via foreground services (one significant difference is that foreground services show up as an icon in your notification area, notice downloads or Play Store updates appear there?). Background services are more like OLE in the sense of they let you set your app up so another app can ask it for stuff.