On Thursday, August 11, 2011 10:25:01 PM UTC+2, Mark Murphy (a Commons Guy) wrote: > > > Please don't write services that way. Use AlarmManager and an > IntentService, so the "sleeping" does not need your service (and > process) tying up RAM. > Of course I'm using AlarmManager. I'm talking about the DVM abstraction level, not activity/service level.
More accurately, it should be: > > working, saving, shutting down, terminated > working, saving, shutting down, terminated > working, saving, shutting down, terminated > working, saving, shutting down, terminated > System.exit()? Since Android keeps the DVM around even after I terminate my services and activities, I thought it would be a nice place to store the state via a singelton object to save flash writes. Then your service should not be in memory to keep the state. You are > wasting RAM and harming the user. Services like yours are why there > are task killers, the Running Services portion of Settings, etc. > Not services like mine, no. Since finalize() wasn't called in the singelton, I tried by using the smallest possible service to catch the onDestroy() to preserve the state. It is not to waste RAM, since Android anyway keeps the objects in the DVM even with every activity and service therein terminated. Why not make use the windfall? Users don't like sloppy developers who keep services in RAM for no > good reason. Guess what? Users win. > A good reason is to save unnecessary flash writes, wouldn't you say? > (I have no clue how long the next sleep will be). > > You have to know "how long the next sleep will be", by definition. > After all, you have to tell Android when to resume operation of your > code, regardless of how you accomplish it (AlarmManager, > Thread.sleep(), postDelayed(), etc.). > I don't control the user, I'm sorry. The question remains, why not onDestroy(), a shutdownhook and/or finalize() before killing of the DVM? -- Mikael Kuisma -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en