Question about Backround Services.

Asked by Excedio

With Background Service disabled, why does it Re-Connect every time I come back from the settings menu? Shouldn't it only do this if I turn on the program or if I do Menu -> Refresh?

Question information

Language:
English Edit question
Status:
Solved
For:
AndroidU1 Edit question
Assignee:
No assignee Edit question
Solved by:
Michał Karnicki
Solved:
Last query:
Last reply:
Revision history for this message
Michał Karnicki (karni) said :
#1

If you choose not to leave the service in the background, it shuts down because the main Activity has unbound from it on the onPause() event, when Preferences was shown. The service runs only when Activity is in the foreground. I'll try to move binding to service to another code section for longer lifetime, and that may solve the problem. I'm leaving the answer open.

Revision history for this message
Excedio (excedio-ubuntu) said :
#2

Thanks for the heads up. An idea might be to have the option for it to "auto refresh." Maybe give an option in Menu -> Settings that will allow the user to choose how often they would like the App the automatically refresh to their U1 account.

Manual Refresh
1 Minute
5 Minutes
10 Minutes
30 Minutes
1 hour
Daily

Revision history for this message
Best Michał Karnicki (karni) said :
#3

I have fixed it (on this pre-alpha stage I should write 'implemented it' instead of fixed ;) ).

Let's name "Service in background" service persistency. It should behave nicely now.

If the service is checked to be persistent, it will run in the background.

If the service is not checked to be persistent, it will stay in the background if visible activities are Main and Prefs (settings). In that mode, the service will shutdown whenever you press:
1. home screen
2. back button
3. future: exit button from Menu -> More

In case of not persistent service, I'll later change it so it first finishes current work and then shuts down (like downloading a starred file, which is a favorite and probably quite important to the user). Right now it could probably (not sure yet) interrupt current download.

Please fetch the new version to confirm :)

Answering your follow-up, it's not that simple. We have to take into consideration server rescan, persistent connection, CPU and battery usage, plus network availability. Plus, 1 to 15 minutes interval would be best for persistent service, since the server notifies about single updates to the content [no need for server rescan, which may be CPU intensive] when there's an ongoing connection. However, if you'd like to sync once every day, maybe it'd be better to execute the app (automatically) and connect, do server rescan, and sync. We'll investigate this more in some time.

In the mean while, if you have ideas for improvements, I'll be happy if you file blueprints (ideas for the project) :)

Thanks for your feedback and the logs.

Revision history for this message
Excedio (excedio-ubuntu) said :
#4

Works nicely. Good job. :-)

FYI...I like the OTHER new feature you added. Uploading. ;-)

Revision history for this message
Excedio (excedio-ubuntu) said :
#5

Thanks Michał Karnicki, that solved my question.

Revision history for this message
Michał Karnicki (karni) said :
#6

I'm glad it works :) gomez has pointed out client reconnects on screen rotation, if the service is selected to not be persistent. I'll fix this, too.