1

我是 Facebook 与 Android 应用程序集成的新手。我正在尝试运行来自Facebook 的应用程序。但它不起作用。我没有得到用户名。为什么它不工作?谁能帮我。

我为会话变量得到了以下一个。

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);
}
4

1 回答 1

1

我有同样的问题,我只是解决这个问题。原因是我的项目处于沙盒模式。禁用沙盒模式,应用程序运行正常 在此处输入图像描述

于 2013-05-09T08:44:14.870 回答