简体   繁体   中英

Integrating Facebook Sharing into my app

Im trying to integrate Facebook sharing into my app.

I am following this guide:

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

Everything went fine till it says:

Add Facebook Activity - Include this in AndroidManifest.xml

which links to:

Add Facebook Activity Link

and no where in that page tells me how to add the activity to my app.

I found a video that did do it but when i type out the code (which doesnt autocomplete) that is in the video to add the activity and try run it. I get the error:

Error:Execution failed for task ':app:processReleaseManifest'.
> Manifest merger failed : Attribute activity#com.facebook.FacebookActivity@theme value=(@android:style/Theme.Translucent.NoTitleBar) from AndroidManifest.xml:27:15-74
  is also present at [com.facebook.android:facebook-android-sdk:4.16.0] AndroidManifest.xml:32:13-63 value=(@style/com_facebook_activity_theme).
  Suggestion: add 'tools:replace="android:theme"' to <activity> element at AndroidManifest.xml:26:5-30:17 to override.

I have done everything else like:

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

in my manifest and:

private void share() {
ShareLinkContent content = new ShareLinkContent.Builder()
        .setContentTitle("This is the title")
        .setContentDescription("This is the description")
        .setContentUrl(Uri.parse("www.google.com"))
        .build();

ShareDialog.show(getActivity(), content);
}

Just as a test but that loads up the share screen, with no info that i specified as well as after a few seconds it crashes?

Please help me?

您需要在AndroidManifest.xml文件中添加Facebook Activity。

<activity android:name="com.facebook.FacebookActivity" />

Add your own custom Facebook activity in manifest along with com.facebook.FacebookActivity.

<activity android:name=".activity.FbActivity" />
    <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" />

Add tools:replace="android:theme" run ok.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM