XMPPConnection is from the Smack XMPP Library.  Any chance you could
provide me with a simple sample code of passing the XMPPConnection
back to the Activity from the Service?  The example you posted is
different than mine, I'm using an Intent to run my service, my service
is going to keep running in the background for a few minutes after the
application is ended.

Bobbie




On Nov 23, 8:42 am, Mark Murphy <mmur...@commonsware.com> wrote:
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to