Because Android doesn't have many programs that should constantly be
consuming background memory and charging through the CPU.  The use
case is things like phones, where you put it in your pocket, and you
just want it to go away.  Remember that you can't do computation
continually if you don't have a wakelock, and if you keep a wake lock
and burn CPU time your users are going to basically hate your app.  If
this is for development, that's one thing, but I can't really think of
many services that should be eating up battery life continuously.

Instead, people use an AlarmManager to occasionally wake up their app,
do some work, then maybe go back to sleep (or run for a while).

So, in short, no, the platform is different, this isn't the days of
the unix daemon where you can just write an app and hope it will live
forever, and very few apps have legitimate use cases for continually
doing computation.  We consistently see people who say "but my app is
different it *really should* be running continuously," and all too
frequently people come to a consensus that the app should not -- in
reality -- be running forever.

Instead, like I mentioned, look into an AlarmManager to wake up your
app on occasion, do some work, and then perhaps schedule a little bit
of time to run.

We all know those apps you download that hold a wake lock forever, try
to connect to a chat service, and then kill your device within three
or four hours.

kris

On Wed, May 9, 2012 at 4:18 PM, William Kelley <williamtkel...@gmail.com> wrote:
> Thanks.
>
> I'm not sure why long running services are frowned upon. As long as they
> don't overly consume resources and are done with the user's knowledge, and
> indeed the user *wants* the features of a long running service, then what is
> the harm? If a user wants to log something for a long time, an everlasting
> service is necessary. And if the user doesn't want this feature, they simply
> don't use the app.
>
>
>
> On Wednesday, May 9, 2012 12:32:17 PM UTC-7, Kristopher Micinski wrote:
>>
>> Right.
>>
>> And in general everlasting services are an antipattern...
>>
>> kris
>>
> --
> 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

-- 
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

Reply via email to