如何使用Android中的PhotoShareContent将描述或标题设置为Facebook照片共享

时间:2016-07-21 05:43:12

标签: android facebook facebook-graph-api

我正在开发一款Android应用。在我的应用程序中,我正在整合Facebook照片共享功能。坦率地说,这是我第一个与Facebook集成的Android应用程序。我现在可以将照片分享到用户时间线。但我在设置描述到该图像时遇到问题。请参阅下面的代码。

这是我的Facebook分享照片功能

 private void sharePhotoToFacebook(){

        SharePhoto photo = new SharePhoto.Builder()
                .setBitmap(shareBitmap)
                .build();

        SharePhotoContent content = new SharePhotoContent.Builder()
                .addPhoto(photo)
                .build();

        ShareApi.share(content, null);

    }

当照片共享时,它会在时间轴中显示

enter image description here

如您所见,没有描述或标题。我想要的是我想设置标题或描述。有没有任何功能可以像下面这样做

SharePhotoContent content = new SharePhotoContent.Builder()
                    .addPhoto(photo).setCaption("Description")
                    .build();

如何设置标题?

2 个答案:

答案 0 :(得分:1)

编写setCaption()方法如下:

    float moveSpeed = 300;
    Vector2 position;
    Matrix viewMatrix;
    int screenwidth, screenheight;
   public void Update(KeyboardState keyState, GameTime gameTime)
    {
        if (keyState.IsKeyDown(Keys.W))
            position.Y -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        if (keyState.IsKeyDown(Keys.S))
            position.Y += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        if (keyState.IsKeyDown(Keys.A))
            position.X -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        if (keyState.IsKeyDown(Keys.D))
            position.X += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        if (position.X < -1000)
            position.X = -1000;
        if (position.Y < -1000)
            position.Y = -1000;
        if (position.X > 1000)
            position.X = 1000;
        if (position.Y > 1000)
            position.Y = 1000;
        viewMatrix = Matrix.CreateTranslation(new Vector3(-position, 0));
    }

注意:需要使用SDK vertion 4+。意味着至少4.1

ArrayA(array('id'=>'1','Date'=>'datehere'),array('id'=>'2','Date'=>'datehere'));
ArrayB(array('ArrayAId'=>'1','personal infos'=>'other data'),array('ArrayAId'=>'1','personal infos 2'=>'other data'),array('ArrayAId'=>'2','personal infos'=>'other data'),array('ArrayAId'=>'2','personal infos 2'=>'other data'));

答案 1 :(得分:1)

根据Facebook平台政策(2.3),您无法从应用中设置标题。请阅读文档中的这个说明。

setCaption(String)

Sets the user generated caption for the photo. Note that the 'caption' must come from the user, as pre-filled content is forbidden by the Platform Policies (2.3).