Use proxy in webview in android

2019-07-20 02:36发布

问题:

I know we can set proxy to webview by using reflection from here. But it doesn't work normally in 4.2.2

I use whatismyip.com to verify whether I am really connected to proxy. And I found that I must rotate the screen (run onCreate the second time) in order to connect to the proxy. So, what is the problem. Thanks

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    WebView wv = (WebView) findViewById(R.id.webView1);
    wv.setWebViewClient(new WebViewClient());
    Util.setProxyICSPlus(wv, "74.221.211.12", 8089, null);
    wv.loadUrl("http://www.whatismyip.com/");
}

WebView android proxy

标签: android proxy