Chavepeyer Geoffrey wrote:
> I'd like to know how I can pass the instance of HttpClient created in
> a first activity to a second activity.

Assuming you really want to do that, you can have the HttpClient be a
public static data member of one of the activities (or some common
utility class) and reference it from any activity that needs it.

> What I'm trying to do is to connect to a webservice that uses sessions
> to handle the identification. Therefore I need to always use the same
> instance of HttpClient so that the sessions is kept alive.

Technically, you only need to share an instance of the CookieStore,
which is where your session cookies would reside. However, it may be
simpler just to share the whole HttpClient as you suggest.

Note that if you are going to be accessing the HttpClient from threads
other than the UI thread -- which is a really good idea -- be sure to
set up the HttpClient for multithreaded use, as demonstrated here:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientMultiThreadedExecution.java

(or http://tinyurl.com/dhu9up if that URL is too long)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android Training in Sweden -- http://www.sotrium.com/training.php

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to