其他分享
首页 > 其他分享> > android – Facebook SDK 4.0 ShareDialog

android – Facebook SDK 4.0 ShareDialog

作者:互联网

我想使用facebook SDK 4.0从我的Android应用程序共享图像.我使用它来使用ShareDialog,但是当用户没有安装FB应用程序时,根据developers.facebook,SDK应该使用Web Share对话框:

In past versions of the SDK for Android, your app had to check for a native, installed Facebook app before it could open the Share Dialog. If the person didn’t have the app installed, you had to provide your own code to call a fallback dialog.

Now the SDK automatically checks for the native Facebook app. If it
isn’t installed the Web Share dialog launches:

但是当我删除FB应用程序并尝试共享时没有任何反应.
这是我的代码:

            ShareDialog shareDialog = new ShareDialog(this);

            BitmapFactory.Options bmOptions = new BitmapFactory.Options();

            bmOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;

            Bitmap image = BitmapFactory.decodeFile(imagePath, bmOptions);

            SharePhoto photo = new SharePhoto.Builder().setBitmap(image).build();

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

            shareDialog.show(content, ShareDialog.Mode.AUTOMATIC);

编辑

有没有办法在没有安装Facebook应用程序的情况下在Facebook上分享照片?

解决方法:

请仔细阅读SDK文档.
在没有安装Facebook App的情况下,您无法与sharedialog共享照片.

参考:https://developers.facebook.com/docs/sharing/android

Photos

People can share photos from your app to Facebook with the Share Dialog or with a custom interface.

The photos must be less than 12MB in size

People need the native Facebook for Android app installed, version 7.0 or higher

标签:android,facebook,facebook-graph-api,facebook-sdk-4-0,facebook-share
来源: https://codeday.me/bug/20190702/1360774.html