You are updating ui from a thread. You should update ui from ui thread only
Toast.makeText(getBaseContext(), res , Toast.LENGTH_LONG).show();
mymoUserName.setText(username);
mymoID.setText(mymoId);
must be in ui thread.
You can use runOnUiThread
.
runOnUiThread(new Runnable() {
@Override
public void run() {
String res = EntityUtils.toString(response.getEntity());
JSONObject result = new JSONObject(res);
Toast.makeText(getBaseContext(), res , Toast.LENGTH_LONG).show();
String username = result.getString("username");
mymoUserName.setText(username);
String mymoId = result.getString("mymo_id");
mymoID.setText(mymoId);
}
});
But you should consider using AsyncTask
. You can do your background operation in doInBackground
update ui onPreExecute
, onPostExecute
and onProgressUpdate