[android-developers] Re: HTTP proxy, android.net.Proxy, Android 1.0
After digging around a bit more I found this thread: http://groups.google.com/group/android-developers/msg/d8cb5935a609b8cc That indicates that the Android Proxy class is (or at least was) for use in setting settings for the built in browser. I personally hadn't thought about a device wide "settings" type proxy that I should be incorporating to my own apps if it's there, but now that you bring it up (if that's what you are trying to do - handle a proxy at run time if it's set, not one you know about beforehand), we all probably should be. That said, you are also correct that the Android Proxy class has no concept of user/pass credentials. In that case if you really want to accommodate for it, you probably need to use that Android Proxy (as you are) AND at the moment allow the user to set the username and password in some kind of settings screen in your own app, if the Android Proxy is set (if you find host/port in the Android Proxy, only then ask them for user pass once in your own app). That is the only way I can think of to handle all the possibilities at the moment. Maybe some Googlers will chime in here and help? It's great that the device wide proxy is there, a sort of global setting (the Android Proxy), but if it doesn't have user and pass it's really only half- baked? (And I haven't accommodated for it yet in my apps at all, should I be doing so, should everyone?) -- As a side note, if you did know the host, port, and user and pass, you can USE a KNOWN proxy just like the HttpClient examples demonstrate: DefaultHttpClient httpclient = new DefaultHttpClient(); httpclient.getCredentialsProvider().setCredentials( new AuthScope("localhost", 8080), new UsernamePasswordCredentials("username", "password")); HttpHost targetHost = new HttpHost("www.verisign.com", 443, "https"); HttpHost proxy = new HttpHost("localhost", 8080); httpclient.getParams().setParameter (ConnRoutePNames.DEFAULT_PROXY, proxy); HttpGet httpget = new HttpGet("/"); On Oct 26, 6:49 pm, Sean Sullivan <[EMAIL PROTECTED]> wrote: > android.net.Proxy has four static methods: > > getDefaultHost > getDefaultPort > > getHost(Context) > getPort(Context) > > According to the javadocs: > > - (getDefaultHost, getDefaultPort) are for a carrier proxy > > - (getHost, getPort) are for a user specified proxy > > I'm looking for methods that will return the user specified proxy > username and password. > > I looked at the source code for android.net.Proxy and I don't see any > methods for > retrieving the username or password: > > http://git.source.android.com/?p=platform/frameworks/base.git;a=blob;... > > Are there other API's that I should be looking at? > > android.net.ConnectivityManager looked promising but I did not see > any > methods for retrieving proxy configuration: > > http://code.google.com/android/reference/android/net/ConnectivityMana... > > android.net.http.AndroidHttpClient doesn't seem to help either. The > source code doesn't > reveal how Android handles proxies: > > http://git.source.android.com/?p=platform/frameworks/base.git;a=blob;... > > Sean > > On Oct 26, 3:32 pm, Charlie Collins <[EMAIL PROTECTED]> wrote: > > > 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/modul... --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: HTTP proxy, android.net.Proxy, Android 1.0
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 android-developers@googlegroups.com 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 -~--~~~~--~~--~--~---
[android-developers] Re: HTTP proxy, android.net.Proxy, Android 1.0
android.net.Proxy has four static methods: getDefaultHost getDefaultPort getHost(Context) getPort(Context) According to the javadocs: - (getDefaultHost, getDefaultPort) are for a carrier proxy - (getHost, getPort) are for a user specified proxy I'm looking for methods that will return the user specified proxy username and password. I looked at the source code for android.net.Proxy and I don't see any methods for retrieving the username or password: http://git.source.android.com/?p=platform/frameworks/base.git;a=blob;f=core/java/android/net/Proxy.java;h=86e1d5b64c6ff9a19b190b4f3100afe9c78e184c;hb=54b6cfa9a9e5b861a9930af873580d6dc20f773c Are there other API's that I should be looking at? android.net.ConnectivityManager looked promising but I did not see any methods for retrieving proxy configuration: http://code.google.com/android/reference/android/net/ConnectivityManager.html android.net.http.AndroidHttpClient doesn't seem to help either. The source code doesn't reveal how Android handles proxies: http://git.source.android.com/?p=platform/frameworks/base.git;a=blob;f=core/java/android/net/http/AndroidHttpClient.java;h=01442aecaac13c7907d98352b259886bf4e6e3d0;hb=54b6cfa9a9e5b861a9930af873580d6dc20f773c Sean On Oct 26, 3:32 pm, Charlie Collins <[EMAIL PROTECTED]> wrote: > 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/modul... > --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---