Bobbie wrote:
> I need to be able to post XMPP messages in my main activity AND a
> service that I am running in the background.  My question is this:
> 
> How can I pass all the XMPP information (including XMPPConnection) to
> the service so it can use it without twice logging in?

Have the service own the XMPP connection, with the activity obtaining
the connection when needed by calling a method on the service object.
The activity can get at the service object via the local binding pattern
or by making the service instance a singleton. The local binding pattern
is cleaner. You can see an example of that here:

http://github.com/commonsguy/cw-android/tree/master/Service/WeatherPlus/

> Currently I have it setup so I am making 2 XMPP connections.  This
> works, my service continues to send XMPP messages UNTIL I try to send
> a message in my main activity, then the app force closes.  Im assuming
> because I have tried to login to the service twice.

You may wish to use adb logcat, DDMS, or the DDMS perspective in Eclipse
to examine the Java stack trace, to validate your assumption.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in Germany, 18-22 January 2010: http://bignerdranch.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

Reply via email to