从活动和服务访问静态类成员,没有得到相同的结果
我有一个静态类
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
}
}
当从主活动中启动的服务调用 EventManager.populateQueue 时,
,该活动和其他活动报告 eventQueue 为空,而该服务不断报告该活动已填充。反之亦然,如果在活动中调用了 populateQueue,服务将报告 eventQueue 为空。
有人可以解释这种行为并提出解决方案吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论