登录后的Facebook的Andr​​oid SDK不公开会议 [英] Facebook Android SDK does not open Session after login

查看:131
本文介绍了登录后的Facebook的Andr​​oid SDK不公开会议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1)出现这个问题很多次,awnser总是你错了键哈希。

1) This question appears many times and the awnser is always "you have the wrong Key Hash".

2)的Facebook的文件告诉我们使用这个code,让我们的密钥散列:

2) Facebook documentation tells we to use this code to get our Key Hash:

keytool -exportcert -alias MyKeyAlias -keystore path\to\my\Key | openssl sha1 -binary | openssl base64

3)好了,这给了我那个键:-1-基********** Q3A

3) Ok, this gives me that key: 1yl**********Q3A

当我尝试登录,我得到了以下信息:     com.facebook.http.protocol.ApiException:(#404)主要散XHA ********** Q10不匹配任何存储的密钥散列

When I try to login, I got the following message: com.facebook.http.protocol.ApiException: (#404) Key hash XHA**********q10 does not match any stored key hashes.

4)然后,我复制并粘贴XHA ********** Q10在我的应用程序设置,那不是我的钥匙要么。

4) Then I copy and paste the XHA**********q10 on my app settings and thats not my key either.

5)所以,我读这是一个code,让你正确的密钥散列文件。这code:

5) So, I read on documentation that was a code that gives you the correct Key Hash. This code:

// Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            "com.facebook.samples.hellofacebook", 
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

它的工作!给了我这个哈希值:+ HA ********** Q0 =

It worked! Gave me this hash: +HA**********q0=

6)我把应用程序设置最后一个散列。是的,我现在可以连接!但是现在我无法打开会话!

6) I put this last hash on app settings and YES, now I can connect! BUT, now I can't open a Session!!!

我用下面的code:

public class FBActivity extends Activity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_view);

        System.out.println("Start Facebook login");
        Session.openActiveSession(this, true, new Session.StatusCallback() {
            public void call(Session session, SessionState state, 
                                              Exception exception) {
                System.out.println("Call");
                if (session.isOpened()) {
                    System.out.println("Open");
                    Request.newMeRequest(session, new Request.GraphUserCallback() {
                        public void onCompleted(GraphUser user, Response response) {
                            System.out.println("Complete");
                            if (user != null) {
                                System.out.println(user.getName());

                            } else {
                                System.out.println("User NULL");
                            }
                        }
                    }).executeAsync();
                } else {
                System.out.println("Not open");
            }

        });
    }
}

和日志是:

开始的Facebook登录

"Start Facebook Login

呼叫

不公开

呼叫

不开

我不知道我还能做什么,因为我已经有正确的密钥散列,我可以做的登录。

I don't know what else can I do, since I already have the correct Key Hash and I can make the login.

推荐答案

我想通了:

下面的方法失踪了。只需将它添加和一切工作。

The following method was missing. Just added it and everything worked.

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

这篇关于登录后的Facebook的Andr​​oid SDK不公开会议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆