@Override public void setTweetsListener(TweetsUpdateListener tweetsListener) { this.tweetsUpdateListener = tweetsListener; String accessToken = PersistUtils.getInstance(context).getAccessToken(); String accessTokenSecret = PersistUtils.getInstance(context).getAccessTokenSecret(); Configuration configuration = new ConfigurationBuilder() .setOAuthConsumerKey(Constants.CONSUMER_KEY) .setOAuthConsumerSecret(Constants.CONSUMER_SECRET) .setOAuthAccessToken(accessToken) .setOAuthAccessTokenSecret(accessTokenSecret) .build(); twitterStream = new TwitterStreamFactory(configuration).getInstance(); twitterStream.addListener(statusListener); twitterStream.user(); }
@Override public void accessToken(Uri uri) { if (requestToken != null) { String verifier = uri.getQueryParameter(INTENT_OAUTH_VERIFIER); try { AccessToken accessToken = twitter.getOAuthAccessToken(requestToken, verifier); PersistUtils.getInstance(context) .persistAccessToken(accessToken.getToken(), accessToken.getTokenSecret()); } catch (TwitterException e) { e.printStackTrace(); } } }
private String getAccessTokenSecret() { if (context != null) { return PersistUtils.getInstance(context).getAccessTokenSecret(); } return ""; }