2015-06-24 51 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); 
相关问题