> Broadcast receivers are only guaranteed to stay around long enough for > their onReceive to complete. They can be destroyed after that, and a new > instance will be created if needed later. >
Given that it creates a new instance of my AppWidgeProvider class for each call, is there a way to have persistent data associated with my widget? That is how can I store data that will still be present on the next call (other than writing it to disk)? Thanks On Jan 11, 12:21 am, Kostya Vasilyev <kmans...@gmail.com> wrote: > 11.01.2011 5:14, John Gaby пишет: > > > I tried adding a class > > member variable, 'm_appWidgetManager', which I set during the onUpdate > > call. However when I get the onReceive call, this value is null. > Right. > > Is > > this because the onReceive is called with a different instance of my > > class, and if so, why is that? > > Broadcast receivers are only guaranteed to stay around long enough for > their onReceive to complete. They can be destroyed after that, and a new > instance will be created if needed later. > > This is what you are seeing - one instance processes onUpdate, then gets > destroyed, and then a new one is created for the next onReceive. > > > If I chang m_appWidgetManager to be > > static, and it all seems to work, but this does not seem like the > > correct solution. > > AppWidgetManager manager = AppWidgetManager.getInstance(context); > > -- > Kostya Vasilyev -- WiFi Manager + pretty widget > --http://kmansoft.wordpress.com -- 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