got NetworkOnMainThreadExeption in a separate Thread
I am trying to connect android app with Twitter and I don't know what's
wrong with this part of my code :
Thread thread = new Thread(){
@Override
public void run() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.setOAuthConsumerKey(TWITTER_CONSUMER_KEY);
builder.setOAuthConsumerSecret(TWITTER_CONSUMER_SECRET);
Configuration configuration = builder.build();
TwitterFactory factory = new TwitterFactory(configuration);
twitter = factory.getInstance();
try {
// Error is here
requestToken =
twitter.getOAuthRequestToken(TWITTER_CALLBACK_URL);
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse(requestToken.getAuthorizationURL())));
} catch (TwitterException e) {
e.printStackTrace();
}
}
};
thread.run();
why I got NetworkOnMainThreadException despite using a new Thread ? thank
you for help..
No comments:
Post a Comment