You are doing a network related operation on the main ui thread. Use a thread or asynctask.
You will get NetworkOnMainThreadexception post honeycomb.
new PostTask().execute();
AsyncTask
class PostTask extends AsyncTask<Void,Void,Void>
{
@Override
protected void doInbackground(Void... params)
{
// network related operation
// do not update ui here
// your http post here
}
}
Also if you use threads or asynctask remember not to update ui in doInbackgroud.
You have this
String msg = msgTextField.getText().toString();
// you can pass msg to asynctask doInbackground or to the asynctask contructor
msgTextField.setText("");
Use onPreExecute and onPostExecute for ui updation.