facebook会议未开幕。已经检查过hashkey

时间:2013-11-08 20:25:55

标签: android facebook

public void facebookButtonPressed(View view) {
    // 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()) {
            Request.newMeRequest(session, new Request.GraphUserCallback() {
                // callback after Graph API response with user object
                @Override
                public void onCompleted(GraphUser user, Response response) {
                    System.out.println("this runs here");
                if (user != null) {
                    Intent intent = new Intent(RegisterAndSignInActivity.this, MainAppActivity.class);
                        startActivity(intent);
                    }   

               }


            }).executeAsync();
            }else {
                System.out.println("this is not opened");
            }
          }
        });
    }

session.isOpened()始终为false 这是我用来获取keyhash的代码

try {
    PackageInfo info = getPackageManager().getPackageInfo(
                    "com.android.trumpeti", 
                    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) {

} 

我尝试过重新生成debug.keystore和使用facebook SDK附带的support-support-v4.jar等建议,但我仍然遇到同样的问题

1 个答案:

答案 0 :(得分:0)

我更喜欢将其作为评论,但我找不到按钮。

您使用的是Facebook sdk附带的LOG IN按钮吗?