Android Facebook sdk 3.5 share dialog

可紊 提交于 2019-12-06 10:17:14

问题


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~


回答1:


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



回答2:


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.




回答3:


Please look at this: This is a useful link https://gist.github.com/jacklt/6700201



来源:https://stackoverflow.com/questions/18604937/android-facebook-sdk-3-5-share-dialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!