On Fri, Jan 23, 2009 at 7:47 AM, g1bb <[email protected]> wrote:

> I realized this right after I posted, by running a bunch of other apps
> while my app was still running. It seems like 'setPersistent' on the
> activity should most likely prevent this. Any ideas?


DO NOT DO THAT.

Please read this: http://code.google.com/android/intro/lifecycle.html

Basically you should have things you want to continue running in the
background implemented as a Service.

Also there is generally no need to create a whole new Thread for this kind
of stuff, you can just post delayed messages to your own handler.

Finally, for something like a countdown timer, you really might want to
consider using the alarm manager so you don't need to keep your app running
at all while it is in the background.  That is the kind of thing a well
behaving Android app will do.  To be able to show the remaining time if the
user returns to your activity, you can store on SharedPreferences the time
the countdown was started.

Using the alarm manager is also the only way you can make sure you execute
when the time expires, even if the user has turned off the phone.


>
>
> Thanks again.
>
> On Jan 23, 8:36 am, Torgny <[email protected]> wrote:
> > Your application background process might get killed if you run
> > another application that takes up a lot of memory, for instance the
> > browser with several windows. As far as I understand it, the
> > application in the foreground takes priority as far as memory and
> > processing power goes over services and threads.
> >
> > On Jan 23, 9:15 am, g1bb <[email protected]> wrote:
> >
> >
> >
> > > Hello,
> >
> > > I've created an app that functions as a countdown timer via a thread,
> > > a wakelock, and a handler back to my activity. My question is, what
> > > will cause my thread to die, or app to not be running in memory
> > > anymore? I've had this happen once, and can't seem to recreate it
> > > again.
> >
> > > Thanks in advance!- Hide quoted text -
> >
> > - Show quoted text -
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support.  All such questions should be posted on public
forums, where I and others can see and answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to