You have NetworkOnMainThreadException
.
http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html
You are running network related operation on the ui thread. Use a thread
or Asynctask
.
http://developer.android.com/reference/android/os/AsyncTask.html
new TheTask().execute();
// can pass parameters to doinbackground or
// can pass param to constructor of asycntask
Then
class TheTask extends AsyncTask<Void, Void, Void> {
protected void doInBackground(Void... params) {
try {
// your twitter code here
// do not update ui ere
} catch (Exception e) {
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
}
}