我正在创建一个Android相机应用程序,我想将它连接到Facebook。 我为我的应用创建了一个页面并创建了一个Open Graph故事" x使用MyApp"拍摄了一张照片。 我使用的是OpenGraphActionDialogBuilder,但出于某种原因,我已经能够在创建的OpenGraphActionDialog中看到附加图像的预览。
这是我的代码:
public void shareWithFacebook(File imageFile) {
// get session
Session session = Session.getActiveSession();
// make sure we have publish permissions
boolean hasPublishPermissions = hasPublishPermission();
if (!hasPublishPermissions) {
if (!session.isOpened()) {
Session.OpenRequest openRequest = new Session.OpenRequest(this);
openRequest.setPermissions("user_friends");
session.openForRead(openRequest);
}
requestPublishPermissions(session);
}
ArrayList<File> files = new ArrayList<File>();
files.add(imageFile);
OpenGraphAction action = OpenGraphAction.Factory.createForPost("mycameraapp:took");
OpenGraphObject picture = OpenGraphObject.Factory.createForPost("mycameraapp:picture");
picture.setProperty("title", "");
action.setProperty("picture", picture);
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "picture" )
.setImageAttachmentFilesForObject("picture", files, true)
.build();
if (FacebookDialog.canPresentOpenGraphActionDialog(this))
shareDialog.present();
}
答案 0 :(得分:0)
您需要添加:
action.setProperty("previewPropertyName", picture);