On 06/18/2010 01:36 PM, Mark Murphy wrote:
On Fri, Jun 18, 2010 at 4:32 PM, mike<[email protected]> wrote:
You should not be attempting to keep an AppWidgetProvider's data in
RAM, for the reasons you have discovered -- these objects have very
short lifespans. If you have state you need to maintain, use a
database or file.
This is just standard Java stuff, right?
What is "this"?
If the program is running, its static variables will be there. If
it stops and is, say, restarted they will be reinitialized.
There's nothing odd or
magical about static in android, right?
No, but processes come and go a bit more frequently than people might
be used to, if they are used to thinking of monolithic Java apps.
Yes, but you know that because onCreate and their ilk, are called again.
AppWidgetProvider is a manifest-registered BroadcastReceiver. These
objects live long enough for onReceive() to be processed. After that,
the process may be recycled or terminated, either of which will nuke
your statics. Hence, do not rely on static data members in
AppWidgetProviders.
Oh, sorry I missed that context. If there are two process contexts,
you obviously shouldn't expect to see statics across the two, unless
there's some strange memory mapping going on, which seems unlikely.
Mike
--
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