当我尝试单击“使用Facebook登录”按钮时,会出现加载动画但没有任何反应。如果我删除所有哈希值,它会打开登录屏幕,但无法说明没有哈希值。我应该使用开发人员还是发布哈希?我到底错过了什么?我用这段代码生成哈希:
try {
PackageInfo info = getPackageManager().getPackageInfo(
"PACKAGE",
PackageManager.GET_SIGNATURES);
for (android.content.pm.Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.wtf("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
修改
我在android片段中登录facebook的代码如下:
loginButton = (LoginButton) fragment.findViewById(R.id.login_button);
loginButton.setReadPermissions("user_friends");
// If using in a fragment
loginButton.setFragment(this);
// Other app specific specialization
// Callback registration
loginButton.registerCallback(C.callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.wtf("onSuccess",loginResult.toString());
}
@Override
public void onCancel() {
Log.wtf("onCancel","");
}
@Override
public void onError(FacebookException exception) {
Log.wtf("onError",exception.toString());
}
});
答案 0 :(得分:0)
您应该将其作为开发人员进行测试并检查Facebook应用设置以及清单中的权限,以确保在此处查看:https://developers.facebook.com/docs/android/getting-started/