我正在尝试将 android 应用程序与 Twitter 连接,但我不知道这部分代码有什么问题:
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();
为什么我得到 NetworkOnMainThreadException 尽管使用了新的 Thread ?谢谢你的帮助..