简体   繁体   English

Android Facebook sdk 3.5分享对话框

[英]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.. 嗨,我正在为Android sdk 3.5实现facebook分享对话框但是我没有取得任何成功我跟随指南..

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? 是MyClass.this错了吗? thanks for reply~ 谢谢你的回复〜

This is what Facebook recommends. 这是Facebook推荐的。 I've just copied the code examples from this link where it is also explained how to handle the uiHelper instance. 我刚刚从这个链接中复制了代码示例,其中还解释了如何处理uiHelper实例。

If you don't care about the results of the dialog it might be ok not to use the uiHelper. 如果您不关心对话框的结果,可以不使用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: 这是Feed对话框的后备:

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

我有这个确切的问题,结果我忘了在</application>标签之前添加<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>我的AndroidManifest.xml。

请看这个:这是一个有用的链接https://gist.github.com/jacklt/6700201

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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