问题
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