2013-12-13 78 views
0

我開發了一個facebook集成應用程序。在應用程序中,首先從本地Facebook應用程序註銷。然後啓動我的應用。它會要求獲得Facebook的憑據。提供詳細信息。它將登錄並顯示我的用戶名。現在關閉應用程序並重新啓動它。它不會再次要求獲取Facebook憑證,自動登錄。直到此,它的行爲是正確的。Facebook集成應用程序在Android中的本機應用程序註銷後未註銷

唯一的問題是,當我從本地應用程序註銷時,它沒有從我的應用程序註銷。它仍在運行先前登錄的會話。我怎樣才能改變這種行爲..

我使用下面的代碼:

Session.openActiveSession(this, true, new Session.StatusCallback() { 

     // callback when session changes state 
     @SuppressWarnings("deprecation") 
     @Override 
     public void call(Session session, SessionState state, Exception exception) { 

      Log.d("Testing", "session opened "+session.isOpened()); 
      Log.d("Testing", "session closed "+session.isClosed()); 
      if (session.isOpened()) { 

      // make request to the /me API 
      Request.executeMeRequestAsync(session, new Request.GraphUserCallback() { 

       // callback after Graph API response with user object 
       @Override 
       public void onCompleted(GraphUser user, Response response) { 

//     Log.d("Testing", "user null or not "+(user == null)); 
       if (user != null) { 
        TextView welcome = (TextView) findViewById(R.id.hello); 
        Log.d("Testing", "user name::: "+user.getName()); 
        welcome.setText("Hello "+user.getName() + "!"); 
       } 
       } 
      }); 
      } 
     } 
     }); 



    } 
     @Override 
     public void onActivityResult(int requestCode, int resultCode, Intent data) { 
      super.onActivityResult(requestCode, resultCode, data); 
      Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data); 
     } 

感謝, 阿瑞丹姆

+1

上摧毀你清除它的工作會議和令牌信息 – Invader

+2

.. @Override protected void onDestroy(){ \t // TODO自動生成方法存根 \t super.onDestroy(); \t Session.getActiveSession()。closeAndClearTokenInformation(); } –

+0

已接受爲答覆。謝謝.. –

回答

2
@Override protected void onDestroy() { 
// TODO Auto-generated method stub 
    super.onDestroy(); 
Session.getActiveSession().closeAndClearTokenInformation(); 
}