2013-04-18 56 views
1

我是新手到Facebook集成到android應用程序。我試圖運行從Facebook getting started.應用程序,但它不工作。我沒有得到用戶名。爲什麼它不起作用?誰能幫我。安卓 - 臉譜示例不工作

我得到了以下一個會話變量。

session: {Session state:OPENING, token:{AccessToken token:ACCESS_TOKEN_REMOVED permissions:[]}, appId:360610310722942}

session opened: false

public class MainActivity extends Activity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // start Facebook Login 
    Session.openActiveSession(this, true, new Session.StatusCallback() { 

     // callback when session changes state 
     @Override 
     public void call(Session session, SessionState state, 
       Exception exception) { 
      final TextView welcome = (TextView) findViewById(R.id.welcome); 
      System.out.println("session: " + session); 
      System.out.println("session opened: " + session.isOpened()); 
      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) { 

           if (user != null) { 

            welcome.setText("Hello " 
              + user.getName() + "!"); 
           } 
          } 
         }); 
      } 

     } 
    }); 
} 

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

回答

1

我有同樣的問題,我只是解決這個問題。 原因是我的項目處於沙盒模式。禁用沙箱模式和應用程序工作正常 enter image description here

+0

在哪種情況下沙盒模式啓用? – naresh

+0

啓用已啓用。禁用爲禁用:|上面的屏幕截圖是禁用的沙盒模式。 – VAdaihiep