Facebook shareDialog doesn't show anything
Asked Answered
C

3

9

I'm trying to share some content's on facebook but i have a lot of problems. i've add the correct keyhash, and created the app on facebook and put it live. When i try to share something it seems good as you can see:

enter image description here

But after i've clicked on post it's empty: enter image description here

It's a permission problem? i've read a lot about this on stack but i can't find an answer that works... That's the code :

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;
    }
Chaff answered 5/12, 2014 at 15:22 Comment(1)
i started a bounty cause i am interested tooHerr
M
2

I had a similar problem.

I fixed it by changing where the picture came from (don't ask me why this worked because I really don't know).

Instead of grabbing my picture URL from websites such as facebook or google play, I uploaded the picture to gethub. With gethub, the picture url ended in a .png. The picture, link and description posted as they were supposed to.

Give this a try. I hope it helps.

Marci answered 10/12, 2014 at 8:28 Comment(1)
just i removed the image and it worked, but i don't know how to add image now.Chantilly
P
0

I think this related to permission, you need to request for publish_actions permission. For the first time facebook will ask for accept the new permission. Once you accepted, the sharedialog will show directly.

This is what I did, But the code i replace with your sharing info.

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

Hope this will help.

Palaeobotany answered 10/12, 2014 at 7:54 Comment(1)
It gave me an error because i have to declare com.facebook.LoginActivity in the manifest, and i've fixed it, but now it give me this error: java.lang.UnsupportedOperationException: Session: an attempt was made to request new permissions for a session that is not currently open.Chaff
I
0

From the latest update of Facebook SDK, Facebook don't allow prefill text. So you can only share URL right now. This is not matter that you are using ShareDialog or Share Intent.

Please see below bug link for more details

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

Illfavored answered 15/12, 2014 at 7:6 Comment(3)
That's a bug about the intent metod, but i'm using the share dialog so i think it's different. Other apps are doing thisChaff
I think bugs in all method. Even sharer.php not working now.You can see this link facebook.com/sharer/sharer.php?u=http://…Illfavored
Now Prefill content is not allowed in any type of Share Method. You can see facebook policy to share content developers.facebook.com/policy/#controlIllfavored

© 2022 - 2024 — McMap. All rights reserved.