1

我制作了一个程序,其中是 facebook 的登录按钮,加载 facebook 登录页面,但立即控制返回相同。包含登录按钮的窗口......同样的程序也在模拟器上很好地执行。

4

2 回答 2

1

使用 facebook api.......

http://blog.doityourselfandroid.com/2011/02/28/30-minute-guide-integrating-facebook-android-application/结帐,如果有帮助,请单击右侧

于 2012-05-07T07:59:02.503 回答
1

查看 Facebook 开发人员 API 文档。

问题正如 Anshuman 所说,您的手机上已经有 SSO,并且尝试再次进行身份验证会导致问题,您需要覆盖onActivityResult并执行特殊的 facebookauthorizeCallback功能:

它是这样的:

            facebook.authorize(SinglePost.this, permissions,
                new DialogListener() {

                    @Override
                    public void onComplete(Bundle values) {
                        // control comes here if the login was successful
                        // Facebook.TOKEN is the key by which the value of
                        // access token is stored in the Bundle called
                        // 'values'
                        Log.d("COMPLETE", "AUTH COMPLETE. VALUES: "
                                + values.size());
                        Log.d("AUTH TOKEN",
                                "== " + values.getString(Facebook.TOKEN));
                        updateStatus(values.getString(Facebook.TOKEN));
                    }

                    @Override
                    public void onFacebookError(FacebookError e) {
                        Log.d("FACEBOOK ERROR",
                                "FB ERROR. MSG: " + e.getMessage()
                                        + ", CAUSE: " + e.getCause());
                    }

                    @Override
                    public void onError(DialogError e) {
                        Log.e("ERROR", "AUTH ERROR. MSG: " + e.getMessage()
                                + ", CAUSE: " + e.getCause());
                    }

                    @Override
                    public void onCancel() {
                        Log.d("CANCELLED", "AUTH CANCELLED");
                    }
                });

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d("onActivityResult", "onActivityResult");
    facebook.authorizeCallback(requestCode, resultCode, data);
}
于 2012-05-07T07:57:07.217 回答