簡體   English   中英

將Facebook共享集成到我的應用中

[英]Integrating Facebook Sharing into my app

我試圖將Facebook共享集成到我的應用中。

我正在遵循此指南:

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

一切順利,直到它說:

添加Facebook活動-將其包含在AndroidManifest.xml中

鏈接到:

添加Facebook活動鏈接

而且該頁面上的任何地方都沒有告訴我如何將活動添加到我的應用中。

我找到了一個做到這一點的視頻,但是當我鍵入視頻中的代碼(不會自動完成)以添加活動並嘗試運行它時。 我得到錯誤:

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.

我已經做了其他所有事情,例如:

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

在我的清單中:

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);
}

就像測試一樣,但它會加載共享屏幕,沒有我指定的信息以及幾秒鍾后崩潰?

請幫我?

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

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

在清單中添加您自己的自定義Facebook活動以及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" />

添加tools:replace =“ android:theme”運行正常。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM