Integrating Facebook Sharing into my app

馋奶兔 提交于 2019-12-13 07:02:48

问题


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?


回答1:


You need to add Facebook Activity in your AndroidManifest.xml file.

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



回答2:


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" />



回答3:


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" />


来源:https://stackoverflow.com/questions/40018701/integrating-facebook-sharing-into-my-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!