gpt4 book ai didi

java - 登录 Facebook registerCallback 未调用

转载 作者:IT老高 更新时间:2023-10-28 23:17:40 27 4
gpt4 key购买 nike

这是我的 onCreate 方法:

@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_social_login);
init();
hideActiveSocialNetworks();
FacebookSdk.sdkInitialize(getApplicationContext());
CallbackManager callbackManager = CallbackManager.Factory.create();
LoginManager.getInstance().registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
// not called
Log.d("fb_login_sdk", "callback success");
}

@Override
public void onCancel() {
// not called
Log.d("fb_login_sdk", "callback cancel");
}

@Override
public void onError(FacebookException e) {
// not called
Log.d("fb_login_sdk", "callback onError");
}
});

final Activity activity = this;

findViewById(R.id.fb_login_sdk).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("fb_login_sdk", "click");
List<String> perm = new ArrayList<String>();
perm.add("user_friends");
LoginManager.getInstance().logInWithReadPermissions(activity, perm);
}
});
}

登录后 onSuccess()、onCancel()、onError() 方法不会被触发。

文档:https://developers.facebook.com/docs/facebook-login/android/v2.3

最佳答案

在我的 Activity 中错过了这个:

   @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}

关于java - 登录 Facebook registerCallback 未调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30599301/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com