1
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 等建议,但我仍然遇到同样的问题

4

0 回答 0