I know how to setting proxy manually and to use it in my WebView.
Settings -> Wireless Networks ->mobile networks-> access point names->telkila. Now enter the proxy server address and port (which will be 80). WebView.enablePlatformNotifications();
But can i set the proxy setting from code? So my user didn't have to set manually?
Thanks
I have adapted the three solutions presented here (and modified one where it failed) to produce a single, simple setProxy method that works for all versions of Android. I've tested it from 10 to 18, and it works for all tested environments.
UPDATED 2014-04-04 I finally worked in the solution from a comment below, courtesy of nubela and xjy2061. Now this works for all current Android versions, including KitKat 4.4. If you implement your own Application subclass, supply the name of the class as the optional fourth parameter.
UPDATED 2015-01-15 The part labeled optional in the KitKat method throws an exception on Lollipop because an auxiliary class is missing, but without that it works on both KitKat and Lollipop, since the WebView is based on Chromium in both cases.
I've made lots of tests and i can says that the previous response using the override based on android.net.http.RequestQueue works perfectly from android 1.6 to 3.1.
But there was a code refactoring on API and to make it work on Android 3.2 & 4.x, here the solution :
enjoy
As @Karthik said, these answers are not work on android 4.4(KitKat). For KitKat the answer was posted here.
madeye's solution https://gist.github.com/madeye/2297083 pseudocode:
is better than birdy's answer(WebView android proxy) pseudocode:
and better than Guillaume13's and MediumOne's answer(WebView android proxy) pseudocode:
but i don't know why that the proxy success only when i insert two lines before setProxy:
Chromium has started obfuscating class names in new release (the class name for the ProxyChangeListener appears to be "bMh" in the latest version, and may change in future releases. So Jimmy Dee's solution will not work anymore for newer versions because the following check will always fail:
A solution that I thought about is to invoke onReceive on all broadcast receivers in the current app-context.
Now I understand this is not an ideal solution, because it may have unwanted side effects by invoking the wrong receivers, and one should scrutinize all broadcast receivers in the app context to make sure they don't do anything bad. (Any other ideas?)
Building on the previous answer, it would be something like this:
It will be really helpful if someone in the community has a better idea.
Firstly, thanks to you all for post codes for fixing proxy settings which its not exist public api to changes in android, its also helped me a lot. I have covered the issues in all of version android a see that it will be need to update this info. Depend on the summary answer of Jimmy above (thanks you !), I tested that its code running incorrectly on android version 3.0 - 3.1 because of android.net.ProxyProperties is not supported and the method updateProxy need for reflection have only by pass java.lang.String input parameter. So, I changed its code by the way, hope that it will helped people have the same issue as me: