You should put your connection code in a thread. try this
new Thread(new Runnable(){
@Override
public void run() {
try {
String URLin = "http://www.android.com/";
URL url = new URL(URLin);
URLConnection connection = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String text = in.readLine();
Log.i("info", "text: " + text);
in.close();
return;
} catch (Exception e) {
Log.e("error", "Error > " + e.getMessage());
}
}
}).start();