我想瀏覽一些帶有代理的網站,我已經擁有了代理(當然還有我想要的應用)。我想以編程方式更改它(無需轉到設置或其他第三方應用程序)。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