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

