It looks like you are trying to make network calls on the UI thread, which is a big no no.
Take a look at how to implement network operations using background threads, specifically ASyncTask
There are literaly 1000's of questions and examples about this.
here is a tutorial to get you started
Also add the necessary permission to your manifest
<uses-permission android:name="android.permission.INTERNET" />