Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Facebook sdk 3.5 share dialog

hi i am implementing the facebook share dialog for android sdk 3.5 however i am not getting any success im following the guides..

FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(MyClass.this)
                            .setApplicationName("App Name")
                            .setName("Name")
                            .setLink("mylink")
                            .build();

i put this inside my on touch method there are no errors appearing but whenever i click the button.. nothing appears also~

is the MyClass.this wrong? thanks for reply~

like image 774
NoobMe Avatar asked Dec 29 '25 17:12

NoobMe


2 Answers

This is what Facebook recommends. I've just copied the code examples from this link where it is also explained how to handle the uiHelper instance.

If you don't care about the results of the dialog it might be ok not to use the uiHelper.

Using the static method to check whether the dialog can be presented is prudent because it only initializes the builder and creates the dialog if it really is possible to present it.

if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
    // Publish the post using the Share Dialog
    FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this)
            .setLink("https://developers.facebook.com/android")
            .build();
    uiHelper.trackPendingDialogCall(shareDialog.present());

} else {
    // Fallback. For example, publish the post using the Feed Dialog
    publishFeedDialog();
}

And this is the feed dialog fallback:

private void publishFeedDialog() {
    Bundle params = new Bundle();
    params.putString("name", "Facebook SDK for Android");
    params.putString("caption", "Build great social apps and get more installs.");
    params.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
    params.putString("link", "https://developers.facebook.com/android");
    params.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");

    WebDialog feedDialog = (
            new WebDialog.FeedDialogBuilder(getActivity(),
                    Session.getActiveSession(),
                    params)).build();
    feedDialog.show();
}
like image 184
Risadinha Avatar answered Jan 01 '26 05:01

Risadinha


I had this exact problem, it turned out I forgot to add <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/> before the </application> tag in my AndroidManifest.xml.

like image 39
John Bale Avatar answered Jan 01 '26 05:01

John Bale



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!