Try this:
Replace this code:
if (TwitterUtils.isAuthenticated(prefs)) {
With the following:
new AsyncTask<SharedPreferences,Object, Boolean>() {
@Override
protected Boolean doInBackground(SharedPreferences... params) {
return TwitterUtils.isAuthenticated(params[0]);
}
@Override
protected void onPostExecute(Boolean isAuthenticated) {
if (isAuthenticated) {
// Do processing after successful authentication
sendTweet();
}
else {
// Do processing after authentication failure
Intent i = new Intent(getApplicationContext(), PrepareRequestTokenActivity.class);
i.putExtra("tweet_msg",getTweetMsg());
startActivity(i);
}
}
}.execute(prefs);