Code example for ConnectivityManager

Methods: requestRouteToHost

0
    private void ensureRoute() throws NoRouteToHostException { 
        int addr = lookupHost(mProxyHost);
        if (addr == -1) {
           throw new NoRouteToHostException("Cannot resolve host: " + mProxyHost);
        } else { 
            if (!mConnMgr.requestRouteToHost(ConnectivityManager.TYPE_MOBILE_MMS, addr) )
                throw new NoRouteToHostException("Cannot establish route to :" + addr);
        } 
    } 
 
    protected HttpResponse requestHttp() throws ClientProtocolException, IOException {
        HttpGet reqGet = new HttpGet(REQUEST_URL);
        DefaultHttpClient client = new DefaultHttpClient();
        HttpParams params = client.getParams();
        Log.d(LOG_TAG, "Proxy: "+mProxyHost + ":" + PROXY_PORT);
        ConnRouteParams.setDefaultProxy(params, new HttpHost(mProxyHost, PROXY_PORT));
        Log.d(LOG_TAG,"UserAgent: " + mUserAgent);
        HttpProtocolParams.setUserAgent(params, mUserAgent);
        reqGet.setParams(params);
        Log.d(LOG_TAG, "HTTP Get: " + REQUEST_URL);
        return (HttpResponse) client.execute(reqGet);