I believe the android.net.Proxy class is intended to be used for
default carrier proxies, which don't require credentials (but rather
use the fact that the device is on the private carrier network as
auth) not for connecting through your own proxy server with
authentication.

You should be able to do your own proxy stuff though, with
credentials, using the straight up HttpClient classes - looks like you
are almost there. Check out the HttpClient 4 examples.

http://hc.apache.org/httpcomponents-client/examples.html

This specific example should work on Android, all these classes are
there (or so it appears from a quick glance):
http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/examples/org/apache/http/examples/client/ClientProxyAuthentication.java

On Oct 26, 3:21 pm, Sean Sullivan <[EMAIL PROTECTED]> wrote:
> My Android application uses HttpClient (org.apache.http.client) to
> connect to a remote web service.
>
> I want my application to play nicely with HTTP proxies.  I examined
> the Android SDK and
> found the android.net.Proxy class.
>
> android.net.Proxy allows my application to get the proxy host
> (getProxyHost) and proxy port (getProxyPort) . However,
> android.net.Proxy does not have any methods for proxy username or
> proxy password.
>
> Am I missing something?
>
> Here's what I've coded so far:
>
>         UsernamePasswordCredentials cred = null;
>
>         // todo : what is the Android API for obtaining HTTP proxy
> username/password?
>
>         hclient.getCredentialsProvider().setCredentials(
>                     new AuthScope(Proxy.getHost(this),
> Proxy.getPort(this)),
>                     cred);
>
>         HttpHost proxy = new HttpHost(Proxy.getHost(this),
> Proxy.getPort(this));
>
> hclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
> proxy);
>
> Cheers,
>
> Sean
--~--~---------~--~----~------------~-------~--~----~
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