Nirav Dangi
Nirav Dangi

Reputation: 3647

How to Sign Out / Log out of Twitter using Oauth on android?

I am doing a Twitter integration.

I do not know how to log out of Twitter.

I am using the following code to try logout... but it's just removing the tokens:

        try
        {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            final Editor edit = prefs.edit();
            edit.remove(OAuth.OAUTH_TOKEN);
            edit.remove(OAuth.OAUTH_TOKEN_SECRET);
            edit.commit();
        }
        catch(Exception e)
        {

        }

Upvotes: 1

Views: 2477

Answers (2)

Kakey
Kakey

Reputation: 4024

You are not logging out of twitter. You are just removing the OAUTH_TOKEN keys from internal storage (Shared Preferences).

Upvotes: 3

Ashish Dwivedi
Ashish Dwivedi

Reputation: 8196

Try this

public void onTwitterLogout() {
    // TODO Auto-generated method stub
    if (mTwitter.hasAccessToken()) {
        mTwitter.resetAccessToken();


    }   else{
        Toast.makeText(context, "You are already logout", Toast.LENGTH_LONG).show();
        }

}

Upvotes: 1

Related Questions