在Android中使用代理的网页流量 [英] Use proxy in webview in android

查看:326
本文介绍了在Android中使用代理的网页流量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以设置代理通过这里利用反射的WebView。不过,这并不在4.2.2正常工作

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

我用whatismyip.com来验证我是否真的连接到代理服务器。而且我发现,我必须旋转屏幕(运行的onCreate第二次),以连接到代理。那么,是什么问题。谢谢

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的Andr​​oid代理

推荐答案

我个人不喜欢你联系的方式。我认为,只有用户应该能够更改代理设置。这也是因为它真的不清楚到Android上的代理服务器设置是如何被处理到所有系统组件(有时我看到了很多的代理设置不同的使用进入了Android的源$ C ​​$ C)。

personally I don't like the method you linked. I think that the only the user should be able to change the proxy settings. This also because it's really not clear into Android how the proxy settings are handled into all the system components (sometimes I saw a lot of different usage of proxy settings into the Android's source code).

不过,我敢肯定,对于具有API版本设备> = 13(蜂窝),你应该只使用一个标准的WebView,依靠用户正确配置了Wi-Fi接入点的事实(包括代理)进入设备设置。

Anyway, I'm quite sure that for devices with API version >= 13 (Honeycomb), you should only use a standard WebView, relying on the fact that the user configured correctly the Wi-Fi Access Point (proxy included) into the device Settings.

您可以在这里找到工作的例子:<一href=\"https://github.com/shouldit/android-proxy-library-demo/blob/master/src/com/lechucksoftware/proxy/lib/activities/WebViewWithProxyActivity.java\" rel=\"nofollow\">https://github.com/shouldit/android-proxy-library-demo/blob/master/src/com/lechucksoftware/proxy/lib/activities/WebViewWithProxyActivity.java

You can find a working example here: https://github.com/shouldit/android-proxy-library-demo/blob/master/src/com/lechucksoftware/proxy/lib/activities/WebViewWithProxyActivity.java

如果您仍然希望更改的Wi-Fi接入点设置(包括代理),您可以使用的 Android的代理库我的工作。

If you still want to change the Wi-Fi Access Point Settings (proxy included) you can use the Android Proxy Library I'm working on.

这篇关于在Android中使用代理的网页流量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆