Sunday, June 16, 2013

Setting up the Android Emulator for HTTP debugging using Fiddler2

Launch an emulator with parameters:

emulator -avd my_avd -http-proxy

Finding proxy:

DefaultHttpClient httpclient = new DefaultHttpClient();

String proxyString = Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.HTTP_PROXY);

if (proxyString != null)
    String proxyAddress = proxyString.split(":")[0];
    int proxyPort = Integer.parseInt(proxyString.split(":")[1]);
    HttpHost proxy = new HttpHost(proxyAddress, proxyPort);

    httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

0 коммент.:

Post a Comment

Powered by Blogger.