How to log out of twitter using Fabric Sdk for Android

I used

Twitter.getSessionManager().clearActiveSession(); 

This does not work, the next time I log in using twitter, it opens a dialog with a browser, accepts the previous login and just asks “Allow the application to receive your data?”, But does not ask for a username and password. help would be appreciated.

+6
source share
6 answers

Finally, I found a solution for this situation.

Incidentally, I found a method on the Twitter SDK for Android

 CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeSessionCookie(); Twitter.getSessionManager().clearActiveSession(); Twitter.logOut(); 

It was very simple, it took me about half an hour to find it.

+28
source

Now that CookieSyncManager is out of date, I do it like this:

 public void logoutTwitter() { TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession(); if (twitterSession != null) { ClearCookies(getApplicationContext()); Twitter.getSessionManager().clearActiveSession(); Twitter.logOut(); } } public static void ClearCookies(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager=CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } } 
+13
source

LAST WORKS:

 public static void logoutTwitter() { TwitterSession twitterSession = TwitterCore.getInstance().getSessionManager().getActiveSession(); if (twitterSession != null) { clearTwitterCookies(mAppContext); Twitter.getSessionManager().clearActiveSession(); Twitter.logOut(); } } public static void clearTwitterCookies(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } } 
+4
source

The above methods are extinct.

 // twitter log out TwitterCore.getInstance().getSessionManager().clearActiveSession(); 
+2
source

Now you can use:

 Digits.logout(); 
+1
source

To log out of the current user, simply call

 mTwitter.shutdown(); 
0
source

Source: https://habr.com/ru/post/985505/


All Articles