使用Facebook分享按钮在Facebook中与标题共享图像仅共享图像

时间:2018-02-10 06:29:01

标签: android facebook facebook-graph-api facebook-share

我正在构建一个应用程序,用户可以使用我在share button中实现的应用程序内的[facebook docs][1]来共享带有消息/标题的图像。问题是图像被共享但消息/标题没有。

代码如下:

MainActivity.java

(在onCreate method内)

shareButton=(Button) findViewById(R.id.shareButton);
    shareDialog=new ShareDialog(this);
    shareButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //selectedContentShare();
            Toast.makeText(getApplicationContext(),"Clicked share",Toast.LENGTH_LONG).show();
            sharePost(imagePost,temp);
            Toast.makeText(getApplicationContext(),temp,Toast.LENGTH_LONG).show();
        }
});

此处imagePost是要共享的图片,temp是邮件/标题。我使用了Toast消息来检查temp是否为null,但它不为空。

正如facebook docs中所述,我实现了share button的功能。代码如下:

onCreate method之外)

public void sharePost(Bitmap imagePost,String temp){
    SharePhoto photo=new SharePhoto.Builder()
            .setBitmap(imagePost)
            .setCaption(temp)
            .build();
    SharePhotoContent content=new SharePhotoContent.Builder()
            .addPhoto(photo)
            .build();
    shareDialog.show(content);
}

此处imagePost是要共享的图片,temp是消息/标题。

[更新]

我在发布带有标题的图片时所遵循的facebook docs,对link to a website quote的{​​{1}}进行了跟踪,然后发布,但image with any texts没有发布。代码如下:

public void sharePost(){
    if (ShareDialog.canShow(ShareLinkContent.class)) {
        ShareLinkContent linkContent = new ShareLinkContent.Builder()
                .setQuote("quote")
                .build();
        shareDialog.show(linkContent);
    }
}

任何人都可以解释并帮助我解释为什么标题没有被分享

1 个答案:

答案 0 :(得分:0)

我认为可能会弃用setCaption

  
    

实施共享时,您的应用不应预先填写要共享的内容。这与Facebook平台不一致     政策,请参阅Facebook平台政策,2.3

  
相关问题