2015-06-24 49 views
1

如果沒有安裝Facebook應用程序,我正嘗試將用戶重定向到瀏覽器以共享來自我的應用程序的照片。在沒有應用程序的情況下在Facebook上分享照片

我使用:

 SharePhoto photo = new SharePhoto.Builder() 
       .setImageUrl(Uri.fromFile(new File(path)) 
       .build(); 

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

     if (ShareDialog.canShow(SharePhotoContent.class)) { 
      //Sharing via facebook app 
      shareDialog.show(content); 
     } else { 
      //Sharing via browser 
      Intent shareCaptionIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/userxxxx")); 
      shareCaptionIntent.setType("image/*"); 

      //set photo 
      shareCaptionIntent.setData(Uri.fromFile(new File(path))); 
      shareCaptionIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); 

      context.startActivity(Intent.createChooser(shareCaptionIntent, "Share image using")); 
     } 

但是到現在爲止沒有任何成功。有沒有辦法共享重定向到Facebook瀏覽器頁面的內容?

+0

我認爲瀏覽器不會獲得額外的數據。 – calvinfly

回答

2

我面臨同樣的麻煩,我可以說,在facebook的SharePhotoContent API中存在一些麻煩。您可以使用ShareLinkContent分享圖片。

ShareLinkContent linkContent = new ShareLinkContent.Builder() 
       .setImageUrl("Your url") 
       .build(); 
shareDialog.show(linkContent); 
相關問題