【发布时间】:2015-06-09 01:25:20
【问题描述】:
我正在使用 Facebook ShareDialog 来分享链接和照片,具体取决于内容。但我看到了一个奇怪的问题。当我单击 shareActionProvider 中的 facebook 图标时,它首先会打开带有空白帖子的 ShareDialog。然后,当我单击返回到我的应用程序时,它会重新打开带有我想要显示的链接/照片内容的 ShareDialog。
这是我用来分享的代码。
....
shareActionProvider.setOnShareTargetSelectedListener(new MyActionProvider.OnShareTargetSelectedListener() {
@Override
public boolean onShareTargetSelected(MyActionProvider source, Intent intent) {
// Recover selected application name for custom action handling
final String appName = intent.getComponent().getPackageName();
switch (appName) {
case "com.facebook.katana": // Facebook
ShareLinkContent content = new ShareLinkContent.Builder()
.setContentUrl(Uri.parse("https://developers.facebook.com"))
.setContentTitle("Check it out!")
.build();
shareDialog.show(content);
break;
....
}
以前有人见过这种行为吗?
谢谢!!
我已经附加了我看到的两个屏幕,以便我看到它们。
编辑
我正在添加更多代码。
我正在使用自定义 ShareActionProvider(完全从 Android 源代码复制,但我覆盖 setOnShareTargetSelectedListener 除外)分享到 FB
在我的活动中onCreate:
FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();
shareDialog = new ShareDialog(this);
shareDialog.registerCallback(
callbackManager,
shareCallback);
当我设置我的ShareActionProvider:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
if (shareActionProvider != null) {
shareActionProvider.setShareIntent(shareIntent);
//... this is before the setOnShareTargetSelected call ....
【问题讨论】:
-
注释掉 shareDialog.show(content);它仍然显示空白对话框吗?
-
@Solarnum 现在它只显示空白对话框。之后没有显示正确的。
-
万岁!那是你的问题。
-
@Solarnum 会很好,除非我没有在其他任何地方明确显示对话框。这么近!
-
你能发布更多你的代码吗?按钮是 facebook lib 提供的按钮吗?
标签: android facebook share facebook-sdk-4.0 facebook-share