1

ShareLinkContent code

ShareLinkContent content = new ShareLinkContent.Builder()
                        .setContentUrl(Uri.parse(shareUrl))
                        .setContentTitle(shareTitle)
                        .build();

Share Dialog codes that I tried

a. Using Share Dialog object

ShareDialog dialog = new ShareDialog(this);
dialog.show(content, ShareDialog.Mode.AUTOMATIC); //tried other 4 modes too

b. Using static access

ShareDialog.show(this, content);

Now the issue is, it works perfectly well in all the regular phones like Motorola, Samsung, Pixel, Lenovo.

But same code is causing weird behaviour in Redmi devices. When I click the button that invokes this code, keyboard and Share dialog appears, stays there for few milliseconds and then disappear.

Am i supposed to anything special to handle Facebook dialogs in MI devices?

There is an option of creating custom dialog box, but I want to keep it as the last option.

Edit

Same is happening with Facebook Like button too.

Here is the code for Facebook like button

facebookLikeView.setObjectIdAndType("https://www.facebook.com/StartupScribble/", LikeView.ObjectType.PAGE);

This code too works perfectly in most of the devices except Redmi devices.

Mohammed Atif
  • 4,383
  • 7
  • 28
  • 57

2 Answers2

6

I had the same problem while developing an app. My problem was that the Facebook-app was still in developer-mode. The Facebook-account that was logged in on the device was not added to the Facebook-app as an Administrator, Developer, or Tester.

The account didn't have permission to access the app, and the share-dialog was closed almost immediately after appearing. This was solved when I logged in with the right Facebook-account.

When testing your apps, place them into development mode. This hides your app entirely from all users who you have not authorized in the App Dashboard to see the app, for the roles described below. Please note that when your app is in development mode, you can't call any API calls on behalf of users who cannot see your app.

The above text comes from the facebook-documentation where they explain more about the roles.

Rockney
  • 10,380
  • 2
  • 20
  • 26
  • Wow! This was strange. Coincidentally all my test devices had my FB account and all the feedbacks that I got from my friends had MI device. So I couldn't even think of this developer and production criteria. I seriously feel, docs where FB guide to integrate these buttons have link to docs where Approvals and publishing is mentioned. Thanks for the help. – Mohammed Atif Mar 07 '17 at 03:10
2

Another reason is because of a bug in native android facebook application in the version of 179.0.0.44.83, in this version, the ShareDialog will not work because of internal bug in Native Facebook Application.

Khalid Taha
  • 3,183
  • 5
  • 27
  • 43
  • im also facing same issue. is there any solution ? @Attila Nyers – A2N Jul 12 '18 at 13:10
  • @A2N the solution is one of two, either you force the dialog to be in web, or the facebook fixes this bug and release a new version – Khalid Taha Jul 15 '18 at 08:42
  • @KhalidTaha Yes. Both happened. FB has fixed this bug in v180 and i have added listener to get error event and open web. Thanks. – A2N Jul 16 '18 at 09:44