1

I want to log out Twitter. I tried to clear reference and request with a new request URI but my account still login. I read this question but it doesn't describe how to login in detail. How to logout Twitter and login with different account? Could you give me some code for logout or relogin?

The function get requet URI

public static String getRequestURI() {
    try {
        final Twitter twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(Constant.CONSUMER_KEY, Constant.CONSUMER_SECRET);

        requestToken = twitter.getOAuthRequestToken(Constant.CALLBACK_URI);
        return requestToken.getAuthenticationURL();
    } catch (final TwitterException e) {
        e.printStackTrace();
    }
    return "";
}

The function clear reference

public static boolean logout(final Context context) {
    getPrefs(context);
    CustomSharedPreferences.setPreferences(Constant.ACCESS_TOKEN, "");
    CustomSharedPreferences.setPreferences(Constant.ACCESS_TOKEN_SECRET, "");
    return true;
}
Community
  • 1
  • 1
emeraldhieu
  • 9,380
  • 19
  • 81
  • 139

1 Answers1

0
mTwitter.setOAuthAccessToken(null);
mTwitter.shutdown();

That works, source http://wenchaokong.blogspot.in/2013/03/android-twitter-integration-twitter4j.html

Sreejith B Naick
  • 1,203
  • 7
  • 13