1

I have a static class

public class EventManager {

    public static Vector<ORMEventData> eventQueue = new Vector<ORMEventData>();

    public static void populateQueue(Context context)
    {
      .... draws items from a database and adds them to the queue
    }

}

when EventManager.populateQueue is called from a service starting in the main activity, that activity and others report eventQueue to be empty, while the service constantly reports that the activity is populated.

the same occurs vice versa, the service will report the eventQueue to be empty if populateQueue has been called in an activity.

Could someone please explain this behaviour and propose a solution?

kameny
  • 2,372
  • 4
  • 30
  • 40
jcage
  • 651
  • 6
  • 14
  • Possible duplicate http://stackoverflow.com/questions/1636500/are-static-fields-in-activity-classes-guaranteed-to-outlive-a-create-destroy-cyc – Tomislav Markovski Dec 21 '11 at 15:50
  • 1
    different processes declared in manifest? – njzk2 Dec 21 '11 at 15:59
  • It could be that the `context` is different between the service and Activity, so due to that it responds differently. Not sure if that's right or how to fix it, but I'd consider it a possible cause. – Reed Dec 21 '11 at 20:52
  • @njzk2: it turns out that this was the reason. the service is declared in the manifest to run into a different process. Thanks for hinting. – jcage Dec 22 '11 at 18:16

0 Answers0