0

I have activity A which has a ListView populated by usernames via the Roster()... On item click it takes you to activity B which is supposed to allow you to send a message to the selected user. Problem is that both activities need XMPPConnection objects which are initialized in my app by logging in... And therefore both activities do separate logins which is super slow. Can someone show me a more efficient way way to do this?

4

1 回答 1

1

我认为您需要将您的登录信息(票证或 sessionId)放入一个单例对象中,例如,您可以添加一个 LoginClient,在这里您可以存储登录信息并执行 http 请求人员。

因为它是带有同步方法的单例,您的两个活动将保留它的实例并检查会话是否无效,然后再次调用登录逻辑并在收到响应后再次替换过期的登录信息.

于 2013-11-07T16:52:53.440 回答