2013-02-04 40 views
4

我正在使用Facebook SDK 3.0登錄我的應用程序。登錄工作正常。一旦我註銷我的應用程序,它不會發生。Android的Facebook的SDK 3.0註銷不工作?

我的註銷代碼:

Facebook mFb=new Facebook("xxxxxxxx"); 
mFb.logout(this); 

給我一些想法做到這一點。

+3

如果您使用的是3.0,請不要再使用Facebook類。該類中的所有方法都已被棄用。請使用新的會話機制。 –

+0

你...我現在工作正常 – Jeeva123

回答

2

答案:正常工作

Session.openActiveSession(this, true, new Session.StatusCallback() { 
@Override 
public void call(final Session session, final SessionState state, Exception exception){ 
    // TODO Auto-generated method stub 
    if(session.isOpened()){ 
     Request.executeMeRequestAsync(session, new Request.GraphUserCallback() { 
      @Override 
      public void onCompleted(GraphUser user, Response response) { 
      // TODO Auto-generated method stub 
       if(user!=null){ 
        try{ 
         session.close(); 
         session.closeAndClearTokenInformation(); 
         //state.isClosed(); 
        }catch (Exception e) { 
         Log.e(tag, "getUserIdMethod--->"+e); 
        } 

       } 
      } 
     });     
    } 
}}); 
2

試試這個:

if(mFb.isSessionValid()) {         
    mFb.logout(getApplicationContext()); 
    SessionStore.clear(getApplicationContext()); 
} 
+0

爲什麼要刪除接受勾號? –

0

做你試圖調用它單獨的線程:

public void logout() 
    { 
     new Thread(){ 
      public void run() { 
       try { 
        mFacebook.logout(your_current_class_name.this); 
       } catch (MalformedURLException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 
      }; 
      }.start(); 
    } 
6

我一直面臨着同樣的問題,終於讓我找到此修復程序

public void logout() 
{ 
    Session session = Session.getActiveSession(); 
    if (session != null) { 
     session.closeAndClearTokenInformation(); 
    } 
    else 
    { 
     Session session2 = Session.openActiveSession((Activity)context, false, null); 
     if(session2 != null) 
      session2.closeAndClearTokenInformation(); 
    } 
    Session.setActiveSession(null); 

} 

我不知道怎麼回事內,但我想我們將不得不建立新的會話,如果沒有找到它,並明確令牌它的信息。 它爲我工作。希望它會有所幫助。

1

對於Facebook來說使用:

LoginManager.getInstance().logOut(); 

註銷。