正在开发一个使用facebook sdk在一个帖子中共享文本和多个图像的应用程序。我使用了以下代码,但在我的fb wall帖子中没有任何反应。什么错误的代码请任何人帮助。提前谢谢。
private void publishImage() {
ArrayList<SharePhoto> sharePhotos = new ArrayList<>();
int imageFolderSize;
File imageFolder = new File(getActivity().getExternalCacheDir(), "attachments/images");
if( imageFolder.exists()) {
imageFolderSize = imageFolder.listFiles().length;
ArrayList<File> attachments = new ArrayList<>();
if (imageFolder.exists()) {
Collections.addAll(attachments, imageFolder.listFiles());
}
if (imageFolderSize > 0) {
for (int i = 0; i < attachments.size(); i++) {
File file = attachments.get(i);
if (file.exists()) {
if (file.getAbsolutePath().endsWith(".png")) {
try {
SharePhoto photo = new SharePhoto.Builder().setBitmap(BitmapFactory.decodeFile(file.getAbsolutePath()))
.setCaption("Welcome To Facebook Photo Sharing on steroids!")
.build();
sharePhotos.add(photo);
}catch (Exception e){
RMLog.debug("Execp: e"+e.toString());
}
}
}
}
}
}
SharePhotoContent scontent = new SharePhotoContent.Builder().addPhotos(sharePhotos
).build();
if(ShareDialog.canShow(SharePhotoContent.class))
{ ShareApi.share(scontent, null);
Toast.makeText(getActivity(), "Succsesfully posted on your wall",
Toast.LENGTH_LONG).show();
}
}