2013-01-10 75 views

回答

2

不需要。 只需撥打session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSIONS));

了權限的(相應修改):

private static final List<String> PERMISSIONS = Arrays.asList("publish_actions"); 

一旦這樣做,你會得到回調:

SessionState.OPENED_TOKEN_UPDATED 

檢查上述狀態&再次發表您的messgae致電:

Request statusRequest=Request.newStatusUpdateRequest(Session.getActiveSession(), mStatus.getText().toString(), reqestCallback); 
if(statusRequest!=null){ 
statusRequest.executeAsync(); 
+0

是這個版本3.0? session.openForRead(...);然後session.requestNewPublishPermission(...),我會得到一個錯誤。 – Yman

+0

是的,它的版本3.0 –

+0

你得到的錯誤是什麼?請更新您的問題與更多細節。 –

0
private class App_Session_StatusCallback implements Session.StatusCallback 
    { 
     @Override 
     public void call(Session session, SessionState state, Exception exception) 
     { 
      Log.d("asd", "state changed"); 
      handleSessionStateChanged(session, state, exception); 
     } 
    } 

    private void handleSessionStateChanged(Session session, SessionState state, Exception exception) 
    { 
     if(state == SessionState.OPENED_TOKEN_UPDATED) 
     { 
      Request statusRequest=Request.newStatusUpdateRequest(Session.getActiveSession(), mStatus.getText().toString(), reqestCallback); 
      if(statusRequest!=null){ 
       statusRequest.executeAsync(); 
      } 
     } 

     if(session != null) 
     { 
      if(session.isOpened()) 
      { 
       Log.d("asd", "session is opened"); 

       Log.d("asd", "Token = " + session.getAccessToken()); 
       Log.d("asd", "Expiry = " + session.getExpirationDate().toGMTString()); 
      } 
      else 
      { 
       Log.d("asd", "session is NOT opened"); 
      } 
     } 
    } 

    Session.getActiveSession().requestNewPublishPermissions(new Session.NewPermissionsRequest(this, Arrays.asList("publish_actions")));