1

我正在創建一個安卓相機應用程序,我想將它連接到Facebook。 我爲我的應用程序創建了一個頁面,並創建了一個Open Graph故事「x使用MyApp拍攝了照片」。 我正在使用OpenGraphActionDialogBu​​ilder,但出於某種原因,我已經能夠在所創建的OpenGraphActionDialog中看到附加圖像的預覽。FacebookDialog.OpenGraphActionDialogBu​​ilder不顯示圖像預覽

這裏是我的代碼:

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

您需要添加:

action.setProperty("previewPropertyName", picture);