android - Facebook 分享对话框未显示 - Android Facebook API
问题描述
单击 facebook 分享按钮后,分享对话框出现并立即消失。在shareDialog.registerCallback
它转到onError
方法中。不明白为什么会这样。
CallbackManager callbackManager;
ShareDialog shareDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FacebookSdk.setApplicationId(String.valueOf(R.string.facebook_app_id));
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() {
@Override
public void onSuccess(Sharer.Result result) {
Toast.makeText(MainActivity.this, "onSuccess", Toast.LENGTH_SHORT).show();
}
@Override
public void onCancel() {
Toast.makeText(MainActivity.this, "onCancel", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException error) {
Toast.makeText(MainActivity.this, "Opps! Some error occurred. Please try again", Toast.LENGTH_SHORT).show();
}
});
bFbShare.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ShareDialog.canShow(ShareLinkContent.class)) {
ShareLinkContent linkContent = new ShareLinkContent.Builder()
.setQuote("Hi ABCE") .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=" + getApplicationContext().getPackageName()))
.build();
shareDialog.show(MainActivity.this, linkContent);
}
}
});
在Logcat我得到这个
GraphResponse: {HttpStatus: 404, errorCode: 803, subErrorCode: -1, errorType: OAuthException, errorMessage: (#803) Some of the aliases you requested do not exist: 2131492917}
解决方案
为我工作if (ShareDialog.canShow(ShareLinkContent.class))
。onClick
推荐阅读
- python - Z3Prover 中的女士或老虎问题
- installation - 哪个 protobuf 版本与 caffe 一起使用?
- graphics - 球对球碰撞解决方案
- javascript - 光标位于带有 React 的自动聚焦文本区域的开头
- c# - 使用反序列化 XML 文件中的多字段 List<> 填充第二个单字段列表 (Xamarin)
- java - JSON 在全选中抛出 java.lang.StackOverflowError
- c# - 在 C# 中使用 Python 库
- javascript - 用于处理日期选择器下拉列表的 JavaScript 对象(三个不同的下拉列表)
- webpack - Webpack 4 - 父文件夹中的 node_modules。如何创建供应商块?
- php - 如果使用 HTML,TCPDF MultiCell 会忽略 valign