Search code examples
facebookandroid-facebookandroid-sharing

Error during sharing text and Image on Facebook using facebook SDK integration


i m getting error during shareing text and Image on Facebook. i used Facebook SDK 4.0 version to integrate into my app

Facebook Analytic showing no error. App opens : 58
when i click on image, Facbook opens and instantly closed, there is no post on my facebook wall. And error shwoing

BlueServiceQueue: Exception during service
  java.lang.Exception: Invalid JSON result
      at com.facebook.appcenter.protocol.FetchAppDetailMethod.a(FetchAppDetailMethod.java:59)
      at com.facebook.appcenter.protocol.FetchAppDetailMethod.a(FetchAppDetailMethod.java:25)
      at com.facebook.graphql.protocol.AbstractPersistedGraphQlApiMethod.a(AbstractPersistedGraphQlApiMethod.java:160)
      at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:186)
      at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:150)
      at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:16)
      at com.facebook.appcenter.service.AppDataServiceHandler.d(AppDataServiceHandler.java:223)
      at com.facebook.appcenter.service.AppDataServiceHandler.a(AppDataServiceHandler.java:103)
      at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:296)
      at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:53)
      at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:230)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
      at java.util.concurrent.FutureTask.run(FutureTask.java:237)
      at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
      at android.os.Handler.handleCallback(Handler.java:733)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:136)
      at android.os.HandlerThread.run(HandlerThread.java:61)

this is the code im using yo share text and Image

if (ShareDialog.canShow(ShareLinkContent.class)) {

     ShareLinkContent content = new ShareLinkContent.Builder()
     .setContentUrl(Uri.parse("https://developers.facebook.com")).build();
     shareDialog.show(getActivity(), content);
}

here is minifest file code

<meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />
        <provider
            android:name="com.facebook.FacebookContentProvider"
            android:authorities="com.facebook.app.FacebookContentProvider@string/facebook_app_id"
            android:exported="true" />

       <activity android:name="com.facebook.FacebookActivity"
            android:configChanges=
                "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:label="@string/app_name" />

i declared String facebook_app_id into string.xml file i do not know why error is showing. i m doing nothing special.

Any suggestion will highly appreciated. thanks in Advance


Solution

  • The reason for opening and closing the Facebook Screen instantly is due to Sandbox settings.

    You need to enable the SandBox mode in the Facebook Developer Page.

    Follow the steps here.

    Open https://developers.facebook.com/ . Select your app from top navigation bar ( Apps ). Click on Status & Review (Left Sidebar). You will find a toggle button to do on/off your app from sandbox mode. [ From Google - This may help some beginners in future ].

    @Ashu Kumar, Thanks for mentioning me to post an answer regarding this.

    Best Wishes.