繁体   English   中英

通过我的应用程序通过Facebook移动应用程序与标题共享照片

[英]Share photo with caption via facebook mobile app from my app

我的应用程序需要共享带标题的照片 。使用Facebok Dialog它是共享的。 如果我安装了Facebook app标题不会出现。 遵循了Facebook sdk latest version 4.2的指示。

这是我在应用程序中用于照片共享的代码。

private void postPhoto() {
        Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.icon);
        SharePhoto sharePhoto = new SharePhoto.Builder().setBitmap(image).setCaption("gbsdfjhbsd").build();
        ArrayList<SharePhoto> photos = new ArrayList<>();
        photos.add(sharePhoto);

        SharePhotoContent sharePhotoContent =
                new SharePhotoContent.Builder().setPhotos(photos).setRef("hjgf").build();
        if (canPresentShareDialogWithPhotos) {
            shareDialog.show(sharePhotoContent);
        } else if (hasPublishPermission()) {
            ShareApi.share(sharePhotoContent, shareCallback);
        } else {
            pendingAction = PendingAction.POST_PHOTO;
            // We need to get new permissions, then complete the action when we get called back.
            LoginManager.getInstance().logInWithPublishPermissions(
                    this,
                    Arrays.asList(PERMISSION));
        }
    }

我正在尝试做同样的事情。 我发现如果在生成器上设置位图是这样的,则它可以正常工作:

// Build SharePhoto
SharePhoto.Builder photoBuilder = new SharePhoto.Builder();
photoBuilder.setBitmap(bitmap);
photoBuilder.setCaption("Caption");
final SharePhoto sharePhoto = photoBuilder.build();

(我正在使用Facebook SDK版本4.5.2)

由于某些晦涩的原因,如果您使用setImageUrl而不是setBitmap,它将不再起作用:-(

据我了解,这并不违反Facebook合同,因为我正在使用它来添加用户输入的文本。 我只是绕过Facebook对话框。

暂无
暂无

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

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