从片段调用时不显示Facebook共享对话框

时间:2015-12-02 06:48:15

标签: android facebook android-fragments facebook-android-sdk android-facebook

我到处都使用Facebook分享,它的工作就像一个魅力但突然在一个片段中共享对话框虽然生成了,我可以在调试时看到Id,虽然它进入函数并且不会抛出任何错误都看不到。

    myHolder.facebookShare.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            shareOnFacebook(position,activity);
        }
        });


    private void shareOnFacebook(int position,Activity activity)
    {
        ShareDialog shareDialog = new ShareDialog(activity);
        String url = "www.prabhukonchada.com";
        String supportMessage="Read More and get latest updates of your favourite superstar on the app";
        String redirectLink = "https://play.google.com/store/apps?hl=en";
        String title = questionModelStoreList.get(position-1).getName();
        String postMessage = questionModelStoreList.get(position-1).getQuestionAsked();
        if(postMessage.length()>65)
        {
            postMessage = postMessage.substring(0,65);
        }
        otherRequiredServices.shareOnFacebook(postMessage.concat("...."),supportMessage,shareDialog,url,title,redirectLink);
    }

// otherRequiredServices.shareOnFacebook is the method below 
    public static void shareOnFacebook(String shareText,String supportingMessage,ShareDialog shareDialog,String url,String title,String redirectLink)
    {
        if (ShareDialog.canShow(ShareLinkContent.class)) {
            ShareLinkContent linkContent = new ShareLinkContent.Builder()
                    .setContentTitle(title+"\" " + shareText +"\"")
                    .setContentDescription(supportingMessage)
                    .setContentUrl(Uri.parse(redirectLink)).setImageUrl(Uri.parse(url))
                    .build();

            shareDialog.show(linkContent);

1 个答案:

答案 0 :(得分:1)

我从没想过这会是罪魁祸首!!!问题在于网址。网址应该类似于" https://play.google.com/store/apps?hl=en"而不是" www.helloworld.com"这是阻止Facebook对话框弹出。