androidtwittertwitter4jandroid-twitter

signout using Twitter4J is not working with android


I am using twitter 4j 3.0.2 jar I have integrate twitter in my android app.I have successfully login and send tweet to twitter account but I face issue in logout from twitter account from my android app.

I implement this as same as twitter4j sample app and I have noticed that same issue also in twitter4j sample app.

Steps I have done

  1. When first time I click on login button from my app then login page of twitter opened. 2.I save token in SharedPreferences. 3.Convert login button to logout. 4.Now I clicked on logout button and clear token from shared preferences. 5.Convert logout button to login 6.Again Click on login then login page of twitter should be opened rather than authorize app page be opened.

My main issue is that how to signout from twitter from android app.Is twitter cache is maintained in anywhere in device ? if yes then how I clear twitter cache from my android app.

Editor e = mSharedPreferences.edit();
        e.remove(PREF_KEY_OAUTH_TOKEN);
        e.remove(PREF_KEY_OAUTH_SECRET);
        e.remove(PREF_KEY_TWITTER_LOGIN);
        e.commit();
        //twitter.shutdown();
        twitter = new TwitterFactory().getInstance();
        twitter.setOAuthConsumer(TWITTER_CONSUMER_KEY,TWITTER_CONSUMER_SECRET);

Solution

  • You need to use force login in twitter. For more details see my previous post

    Twitter Login Dialog error

    So you just need to add force_login=true in your authorize url i.e

    http://twitter.com/oauth/authorize?force_login=true