Android 在 Facebook 墙上分享带有文字的屏幕截图

Android share screenshot with text on facebook wall

朋友们您好,我在 Facebook 墙上分享功能时遇到了问题。我正在共享文本和图像,这是我的应用程序的捕获屏幕。但我无法使用以下代码共享文本。请帮我解决这个问题。

Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
        shareIntent.setType("image/png");
        shareIntent.putExtra(Intent.EXTRA_TITLE, "my awesome caption in the EXTRA_TITLE field");
        shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "your sharing text");
        shareIntent.putExtra(android.content.Intent.EXTRA_STREAM, pngUri); // Share
                                                                            // the
                                                                            // image
                                                                            // on
                                                                            // Facebook
        PackageManager pm = mActivity.getPackageManager();
        List<ResolveInfo> activityList = pm.queryIntentActivities(shareIntent, 0);
        for (final ResolveInfo app : activityList)
        {
            if ((app.activityInfo.name).contains(sharingapp))
            {
                c++;
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName, activity.name);
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setComponent(name);
                startActivity(shareIntent);
                break;
            }

        }

与其使用 Intent 在 facebook 中分享,不如尝试使用他们的 WebDialog 分享。使用 Intent 并不总是可靠的。 (对不起我的英语:))

这是我的示例代码:

Bundle params = new Bundle();
        params.putString("name", name);
        params.putString("caption", caption);
        params.putString("description", desctription);
        params.putString("picture", image);

        WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(context, Session.getActiveSession(), params))
                .setOnCompleteListener(new WebDialog.OnCompleteListener() {
                    @Override
                    public void onComplete(Bundle values, FacebookException error) {
                        if (error == null) {
                            final String postId = values.getString("post_id");
                            if (postId != null) {
                                ShareDialog.this.dismiss();
                                Toast.makeText(context, "Shared Successfully", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(context.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                            }
                        } else if (error instanceof FacebookOperationCanceledException) {
                            // User clicked the "x" button
                            Toast.makeText(context.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(context.getApplicationContext(), "Error posting story", Toast.LENGTH_SHORT).show();
                        }
                    }
                })
                .build();
        feedDialog.show();