facebook api for android“session.isOpened();”总是返回假

时间:2013-04-25 06:33:48

标签: java android facebook

我是android facebook api的新手我想在我的墙上贴标签剪切图像,但会话总是返回false。 我已经完成了密钥哈希等所有步骤。

      // 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) {
            if (session.isOpened()) {
                Toast.makeText(getApplicationContext(), "da ho tost ka kana", Toast.LENGTH_LONG).show();
                publishStory();
                // 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) {
                          publishStory();
                          Toast.makeText(getApplicationContext(), "Hello " + user.getName() + "!", Toast.LENGTH_SHORT).show();
                          com.actionbarsherlock.app.ActionBar actionBar = getSupportActionBar();
                          actionBar.setTitle(user.getFirstName());
                        }
                  }
                });
            }
        }
      });

这是关于活动结果

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

session.isopened();总是返回false;

1 个答案:

答案 0 :(得分:0)

当我从设备中删除Facebook应用程序时,它可以正常工作。 为了使用Facebook应用程序,您应该创建一个相关密钥。 考虑这些链接

Facebook API login fails with FB app installed on phone

App is misconfigured for Facebook Login with Release Key Hash

回答这个问题中的两个

Key hash for Android-Facebook app