我使用 Twitter4j 来获取带有标签的状态:
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("*******")
.setOAuthConsumerSecret("****")
.setOAuthAccessToken("*****")
.setOAuthAccessTokenSecret("*****");
TwitterFactory tf = new TwitterFactory(cb.build());
Twitter twitter = tf.getInstance();
Query query = new Query("source:twitter4j yusukey");
QueryResult result;
try {
result = twitter.search(query);
for (Status status : result.getTweets()) {
System.out.println("@" + status.getUser().getScreenName() + ":" + status.getText());
}
} catch (TwitterException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我用键替换*,但应用程序无法启动
java.lang.RuntimeException:无法启动活动 ComponentInfo{com.example.app_evnt/com.example.app_evnt.SocialNetwork}:android.os.NetworkOnMainThreadException