tags:

views:

49

answers:

1

Are Activities in the background considered "running" (and can execute code) or are they in a suspended state?

+3  A: 

They are paused: Activity Life Cycle, so you cannot execute code from there.

alt text

Cristian
More accurately, they will not be called on the main application thread while paused, until resumed. However, other threads forked by the activity can and will still run. This is not a good idea for the long term, as you have no idea how long the activity will be paused (seconds? days?) and keeping a thread going will chew up RAM and CPU time. But if you, say, kicked off an `AsyncTask`, you don't have to worry about it if the activity is paused -- it will continue to run to completion.
CommonsWare
Having a thread sitting there doing nothing (just waiting for something to do) is fine. That is, after all, what the main thread is doing.Note that you can also continue to have work done on the main thread with a Handler, it will still get callbacks for things like registerReceiver(), etc.
hackbod