简体   繁体   中英

Facebook share dialog not displayed while calling from a fragment

I have used Facebook share everywhere and it works like a charm but suddenly in one fragment the share dialog though generated and I can see the Id while debugging and though it enters the function and doesn't throw any error cannot be seen.

    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);

I never thought this would be the culprit !!! The problem is with the url.The url should be something like " https://play.google.com/store/apps?hl=en " and not "www.helloworld.com" which is stopping the Facebook dialog to pop up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM