Hi,

I have read a lot about being careful with Context when it comes to
memory leaks e.g TextView tv = new TextView(this) not being available
for garbage collection until the activity has finished. However my
problem is trying to CREATE this situation.

I have a service running in the background with an XMPPConnection
(from the aSmack XMPP library). However it seems it is getting
collected by the GC even when the service is still running.

Currently I am using
XMPPConnection connection = new XMPPConnection(connectionConfig);

to create the connection but I want to link it to the service like in
the TextView example using something like this:

XMPPConnection connection = new XMPPConnection(this,
connectionConfig).

Am I right in thinking that this will protect it from the GC while the
service is still running? And, if yes, what do I do with the service
context after it has been passed to XMPPConnection?
I have looked at some examples and seen 'super(context)' but have not
been able to find an explanation of this anywhere.

Thankyou in advance for your help and apologies that I am not very
good at explaining things.

Harry

-- 
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