2016-07-21 28 views
0

我正在開發一個Android應用程序。在我的應用程序中,我正在整合Facebook照片分享功能。坦率地說,這是我與Facebook整合的第一款Android應用程序。我現在可以將照片分享給用戶時間軸。但是我在設置描述到該圖像時遇到問題。請參閱下面的代碼。如何在Android中使用PhotoShareContent設置Facebook照片分享的描述或標題

這是我的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(); 

我該如何設置標題?如下

回答

1

寫setCaption()方法:

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

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

compile 'com.facebook.android:facebook-android-sdk:4.+' 
+0

我無法訪問設置字幕方法 –

+0

它表示不存在與紅線原因setCaption方法錯誤。 –

+0

哦,你好。我的SDK版本太低。我更新了它,現在我可以看到它。怎麼樣分享像這個新的SharePhotoContent.Builder() .addPhotos(sharePhotos) .build(); 。我不想爲每張照片設置標題。我想爲所有照片設置一個標題。我怎樣才能得到它? –

0

根據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).

+0

目前我使用setCaption並且它是成功的。你的意思是如果我的應用程序上線,它不會工作? –

+0

即使您的應用程序沒有運行,這也不起作用。解釋說明了這一切。令人失望。字幕非常有用。 – chitgoks

相關問題