我可以成功分享到Facebook帖子,但无法获得任何回调,知道它是否成功。我尝试调试它,结果onActivityResult永远不会被调用。这很奇怪,因为我的fblogin按钮实际上使用相同的callbackmanager,正常调用onActivityResult。
这是我的相关代码:
aCallbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(
aCallbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onCancel() {
Log.d("Facebookshare", "Canceled");
}
@Override
public void onError(FacebookException error) {
Log.d("Facebookshare", String.format("Error: %s", error.toString()));
String title = getString(R.string.app_name);
String alertMessage = error.getMessage();
showResult(title, alertMessage);
}
@Override
public void onSuccess(Sharer.Result result) {
Log.d("Facebookshare", "Success!");
if (result.getPostId() != null) {
String title = getString(R.string.app_name);
String id = result.getPostId();
String alertMessage = getString(R.string.app_name);
showResult(title, alertMessage);
}
}
});
和
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Pass the activity result back to the Facebook SDK
if (mCallbackManager!=null && requestCode != RC_SIGN_IN) {
mCallbackManager.onActivityResult(requestCode, resultCode, data);
} else if (aCallbackManager!=null && requestCode != RC_SIGN_IN) {
aCallbackManager.onActivityResult(requestCode, resultCode, data);
}
else {
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// [START_EXCLUDE]
Toast.makeText(MainActivity.this, "GoogleSignIn failed",
Toast.LENGTH_SHORT).show();
// updateUI(null);
// [END_EXCLUDE]
}
}
}
}
我的onActivityResult
grep -Ev '<your regex>'