Google+ 分享对话框显示错误图片

Google+ share dialog show wrong image

我正在尝试使用此 method:

Google+ 上分享图片和标题
share(com.google.android.apps.plus, img, title);
====================================
private void share(String type, int imgResId, String title) {
        boolean found = false;
        Intent share = new Intent(android.content.Intent.ACTION_SEND);
        share.setType("image/jpeg");

        // gets the list of intents that can be loaded.
        List<ResolveInfo> resInfo = context.getPackageManager()
                .queryIntentActivities(share, 0);
        if (!resInfo.isEmpty()) {
            for (ResolveInfo info : resInfo) {

                if (info.activityInfo.packageName.toLowerCase(
                        Locale.ENGLISH).contains(type)
                        || info.activityInfo.name.toLowerCase(
                                Locale.ENGLISH).contains(type)) {
                    Log.d("pack", info.toString());
                    share.putExtra(Intent.EXTRA_SUBJECT, "subject");
                    share.putExtra(Intent.EXTRA_TEXT, title);
                    share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(Helper
                            .saveFile(context, imgResId))); // Optional,
                                                            // just if you
                                                            // wanna share
                                                            // an image.
                    share.setPackage(info.activityInfo.packageName);
                    found = true;
                    break;
                }
            }
            if (!found)
                return;

            context.startActivity(Intent.createChooser(share, "Select"));
        }
}

Google+ share dialog 出现时它显示了错误的图像(我第一次尝试在 Google+ 上分享的图像)。我尝试更改图像 resource id 但仍然是同样错误的图像。

我 运行 在尝试为不同的文件重用 URI 时遇到了同样的问题,某处似乎有一个图像缓存,它没有注意到图像已更改。

我 "fixed" 它通过为新图像生成不同的 URI(在您的情况下,每次使用唯一的文件名)。更好的解决方案是使该缓存无效,但我不知道如何(或是否)可以做到这一点。