Facebook shareDialog没有显示任何内容

时间:2014-12-05 15:22:26

标签: android sharing facebook-sdk-3.14.x

我试图在Facebook上分享一些内容,但我遇到了很多问题。 我添加了正确的keyhash,并在facebook上创建了应用程序并将其置于活动状态。 当我尝试分享一些看起来很好的东西,你可以看到:

enter image description here

但是在我点击发布后它是空的: enter image description here

这是一个许可问题吗?我已经在堆栈上阅读了很多关于此的内容,但我无法找到有效的答案...... 那是代码:

public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) 
        {
            case R.id.action_share:         
                Intent intent2=new Intent(Intent.ACTION_SEND);
                intent2.setType("text/plain");
                intent2.putExtra(Intent.EXTRA_TEXT,"'"+ random + "'" + "\n"+"By Random Quotes"); 
                startActivity(Intent.createChooser(intent2, "Share via"));
                break;

                case R.id.randombut:
                     Frasi();

                case android.R.id.home:
                    Intent homeIntent = new Intent(this, MainActivity.class);
                    homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(homeIntent);
                break;

                case R.id.facebook:
                    FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
                    .setApplicationName("Random Quotes")
                    .setDescription(random)
                .setPicture("https://lh6.ggpht.com/1UJ89ho9pvVLPYS6NsFVQdb7KoQPALMhkw1w7DnNDqcfDYJ-tRxruaf2YLMLyqhnG_g=w300-rw")
                    .setLink("https://play.google.com/store/apps/details?id=com.techappstudios.randomquotes")
                    .build();
                    uiHelper.trackPendingDialogCall(shareDialog.present());

         }
        return true;
    }

3 个答案:

答案 0 :(得分:2)

我有类似的问题。

我通过改变图片的来源来修复它(不要问我为什么这样,因为我真的不知道)。

我没有从Facebook或Google Play等网站抓取我的图片网址,而是将图片上传到了gethub。使用gethub,图片网址以.png结尾。图片,链接和描述按照预期发布。

试一试。我希望它有所帮助。

答案 1 :(得分:0)

我认为这与权限有关,您需要请求publish_actions权限。 Facebook将首次要求接受新的许可。一旦您接受,sharedialog将直接显示。

这就是我所做的,但代码我用您的共享信息替换。

final Session activteSession  = Session.getActiveSession();
        if(!activteSession.isPermissionGranted("publish_actions")) {
            Session.getActiveSession().requestNewPublishPermissions(new Session.NewPermissionsRequest(this, "publish_actions"));
        }
        FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
                .setApplicationName("Random Quotes")
                .setDescription(random)
            .setPicture("https://lh6.ggpht.com/1UJ89ho9pvVLPYS6NsFVQdb7KoQPALMhkw1w7DnNDqcfDYJ-tRxruaf2YLMLyqhnG_g=w300-rw")
                .setLink("https://play.google.com/store/apps/details?id=com.techappstudios.randomquotes")
                .build();
                uiHelper.trackPendingDialogCall(shareDialog.present());
        mFacebookUIHelper.trackPendingDialogCall(shareDialog.present());

希望这会有所帮助。

答案 2 :(得分:0)

从Facebook SDK的最新更新来看,Facebook不允许预填充文本。所以你现在只能分享网址。这与您使用ShareDialog或Share Intent无关。

请参阅以下错误链接了解更多详情

https://developers.facebook.com/bugs/332619626816423