简体   繁体   English

在Android上创建Facebook Like按钮

[英]Creating a Facebook Like button on Android

I'm trying to provide a Facebook Like button in my Android app and am having problems. 我试图在我的Android应用程序中提供一个Facebook Like按钮,但是出现问题。 I think that I have everything set up properly: 我认为我已正确设置了所有内容:

I'm calling FacebookSdk.sdkInitialize(getApplicationContext()); 我在叫FacebookSdk.sdkInitialize(getApplicationContext());

I've added a LikeView into my activity 我在活动中添加了LikeView

I've created an app id using the appropriate key hashes 我已经使用适当的密钥哈希创建了一个应用程序ID

I've added the following into the manifest inside the application tag: 我已将以下内容添加到application标签内的清单中:

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

    <provider android:authorities="com.facebook.app.FacebookContentProvider000000000099893"
      android:name="com.facebook.FacebookContentProvider"
      android:exported="true"/>       

Where 000000000099893 is my application id (I've zeroed out most of it) 其中000000000099893是我的应用程序ID(我已将其大部分清零)

My app is crashing in Facebook's Utility.java class on the line: 我的应用程序在Facebook的Utility.java类中崩溃了:

FetchedAppSettings settings = fetchedAppSettings.get(applicationId);

Actually it crashes within the HashMap code with a null pointer 实际上,它使用空指针在HashMap代码内崩溃

This leads me to believe that something is going wrong with my application id. 这使我相信我的应用程序ID出了点问题。 What else should I be looking at? 我还要看什么?

Okay, after going through all of the code in the SDK and some of the samples I finally figured out what was going on. 好的,在浏览完SDK中的所有代码和一些示例之后,我终于弄清楚了发生了什么。 It seems that I need to add 看来我需要补充

<meta-data android:name="com.facebook.sdk.ApplicationId"                android:value="@string/app_id"/>
<meta-data android:name="com.facebook.sdk.ApplicationName"
android:value="@string/facebook_app_name" />

into the manifest. 进入清单。

I just downloaded the SDK today - it says that the version is 4.2.0 but the instructions on the Facebook site do not mention these manifest changes. 我今天刚刚下载了SDK-它说版本是4.2.0,但是Facebook网站上的说明没有提及这些明显的更改。

Disappointed. 失望了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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