我想浏览一些带有代理的网站,我已经拥有了代理(当然还有我想要的应用)。我想以编程方式更改它(无需转到设置或其他第三方应用程序)。Android代理设置
这里是我做了什么:
public class WebViewActivity extends Activity {
WebView web;
String PROXY_IP = "MyProxy";
int PROXY_PORT = MyPort;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view);
web = (WebView) findViewById(R.id.webView1);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("MyURL");
if (PROXY_IP != null) {
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getCredentialsProvider().getCredentials(new AuthScope(PROXY_IP, PROXY_PORT));
new UsernamePasswordCredentials("username","passsword");
HttpHost proxy = new HttpHost(PROXY_IP, PROXY_PORT);
}
}
我使用的WebView这一点。我已经尝试过使用phonegap并且只是编辑资产。但我对一些php代码感到困惑。所以我决定使用webview。
问题是如何使用我的代理使我的webview。
注意:我正在使用GB 2.3
它不适合webview。但其获取数据 – Nicolas 2013-05-14 04:53:33