Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rules for Android background tasks (or apps)

 
Russell Bateman
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a recent Android developer. I have an app that I'd like to work in the background, going to "sleep" for most hours each day and, at other times, checking for server state every 1 hour and, over a brief period of just a few hours, every 10 minutes or so. If there were a change in state, it might display some notice of this (a Toast or something else appropriate).

I've pored over myriad posts and discussions about how "evil" background apps are on Android. There are even apps created to help the device owner manage, especially, kill them. I certainly do not want my app to do the wrong thing.

I have also read that the Android OS will actually kill apps that aren't in active use. My app would probably be asleep from late evening until early to mid-afternoon knowing that there would be no server state to be concerned about until then. Would it not therefore be tossed out and no longer in the background?

I'm interested in a link to an authoritative article that covers the best practice for such things and, if possible, good design for them as well. Alternatively, my ears are wide-open if someone wanted to pontificate directly here. I would be most grateful for any and all comments.

Thanks,

Russ Bateman
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Android may kill Activities that are not in use. But Activities are supposed to interact with the user, and they can't do that anyway if they're in the background. But there are also Services, which run only in the background, and sound exactly like what you're looking for. See http://developer.android.com/guide/topics/fundamentals.html for descriptions of the basic building blocks for Android apps.

And yes, a user -or a process manager he configures accordingly- can kill any process, but presumably a user would want your background service to run; so I don't see that as a problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic