HttpClient do Android: NetworkOnMainThreadException

Eu tenho algum código abaixo:

protected void testConnection(String url) {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    HttpGet httpget = new HttpGet(url);
    ResponseHandler<String> responsehandler = new BasicResponseHandler();

    try {
        String connection = httpclient.execute(httpget, responsehandler);
        Toast.makeText(getBaseContext(), R.string.connection_succeed, Toast.LENGTH_SHORT).show();
        view_result.setText(connection);
    } catch(IOException e) {
        Toast.makeText(getBaseContext(), R.string.connection_failed, Toast.LENGTH_SHORT).show();
    }
    httpclient.getConnectionManager().shutdown();
}

e adicione uma permissão no Menifest:

<uses-permission android:name="android.permission.INTERNET"/>

Mas vai uma exceção: NetworkOnMainThreadException, como posso fazer?

questionAnswers(4)

yourAnswerToTheQuestion