在android中使用intent在facebook上共享多幅带有标题的图片

6pp0gazn  于 2021-07-09  发布在  Java
关注(0)|答案(2)|浏览(354)

我想使用intent在facebook上共享多幅带有标题的图片。我试过一些方法,但没用。我可以分享照片,但不能分享标题。你能帮帮我吗?谢谢!!!
我的共享功能

private void share(String nameApp, ArrayList<String> imagePath, String text) {
        try {
            List<Intent> targetedShareIntents = new ArrayList<Intent>();
            Intent share = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
            share.setType("image/*");
            List<ResolveInfo> resInfo = getActivity().getPackageManager().queryIntentActivities(share, 0);
            if (!resInfo.isEmpty()) {
                for (ResolveInfo info : resInfo) {
                    Intent targetedShare = new Intent(
                            android.content.Intent.ACTION_SEND_MULTIPLE);
                    targetedShare.setType("image/*"); 
                    if (info.activityInfo.packageName.toLowerCase().contains(nameApp)           
                            || info.activityInfo.name.toLowerCase().contains(nameApp)) {
                        ArrayList<Uri> uris = new ArrayList<Uri>();
                        for (int i = 0; i < nImageCount; i++){
                            uris.add(Uri.parse("file://" + imagePath.get(i)));
                        }
                        targetedShare.putExtra(Intent.EXTRA_TITLE, text);
                        targetedShare.putExtra(Intent.EXTRA_TEXT, text);
                        targetedShare.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
                        targetedShare.setPackage(info.activityInfo.packageName);
                        targetedShareIntents.add(targetedShare);
                    }
                }
                Intent chooserIntent = Intent.createChooser(
                        targetedShareIntents.remove(0), "Select app to share");
                chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                        targetedShareIntents.toArray(new Parcelable[] {}));
                startActivity(chooserIntent);
            }
        } catch (Exception e) {
        }
    }
2ul0zpep

2ul0zpep1#

我从facebook开发者那里得到了答案。因为他们的政策,他们不再支持了。
他们说“这个问题将通过设计来解决,因为我们的api不支持为用户预填充消息,正如我们在这里的策略文档中看到的那样(https://developers.facebook.com/docs/guides/policy/application_integration_points/)平台下政策iv.2”
https://developers.facebook.com/x/bugs/332619626816423/

2cmtqfgy

2cmtqfgy2#

首先,你没有使用 EXTRA_SUBJECT ,这是我希望的“标题”去。
第二,没有 EXTRA_TITLE 在文档中 ACTION_SEND_MULTIPLE .
第三,没有任何应用程序必须遵守的要求 EXTRA_SUBJECT 为了 ACTION_SEND_MULTIPLE .

相关问题