Code example for DefaultHttpClient

Methods: execute

                    try { 
                        // Note: not using AndroidHttpClient, as that comes with its 
                        // own pre-StrictMode network-on-Looper thread check.  The 
                        // intent of this test is that we test the network stack's 
                        // instrumentation for StrictMode instead. 
                        DefaultHttpClient httpClient = new DefaultHttpClient();
                        HttpResponse res = httpClient.execute(
                            new HttpGet(""));
                        Log.d(TAG, "Fetched http response: " + res);
                    } catch (IOException e) {
                        Log.d(TAG, "HTTP fetch error: " + e);
        final Button http2Button = (Button) findViewById(;
        http2Button.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    try { 
                        // Usually this ends up tripping in DNS resolution, 
Contextual code suggestions in your IDE  Get Codota for Java