"Android Learning Notes" Facebook SDK readiness conditions

Source: Internet
Author: User

1.Sign up for FaceBook 's developer account and create apps.

2.Download and install the Android Facebook SDK and import into Eclipse

:Https://developers.facebook.com/docs/android/?locale=zh_CN

3, in your project correctly import Lib, mainly to import the Facebook SDK, such as:

4.then open res/values/strings.xml, add the string "facebook_app_id"

Where:appId is automatically generated when you register an app on Facebook

5. Configure androidmanifest.xml, add permissions and Meta-data

<uses-permission android:name= "Android.permission.INTERNET"/> <meta-dataandroid:name= " Com.facebook.sdk.ApplicationId "android:value=" @string/facebook_app_id "/>

6. Then go back to the Facebook app and fill in the name of the package name and the main Activity.

7. Use code to view key hash, add this code and run

try {packageinfo info = Getpackagemanager (). Getpackageinfo ("Com.example.kam", packagemanager.get_signatures); for ( Signature signature:info.signatures) {messagedigest MD = messagedigest.getinstance ("SHA"); Md.update ( Signature.tobytearray ()); LOG.E ("Keyhash:", Base64.encodetostring (Md.digest (), Base64.default));}} catch (Namenotfoundexception e) {} catch (NoSuchAlgorithmException e) {}


Eg. after running, get: sglgmxlutbyuyk34ffufgzdypb8=

Ps. It is important to note that the new version of Eclipse New project, if can be compatible with the old version and automatically generate appcompat_v7 This package, May and FACEBOOKSDK inside of the conflict. Duplicate class libraries are used and the versions are inconsistent. Causes the lower version to be used preferentially. All we have to do is delete the APPCOMPAT_V7 library.

8. In order to output the log of the program activity event, the on Resume () method in the main activity is added The following code:

@Override    protected void Onresume () {      super.onresume ();      Logs ' Install ' and ' app activate ' app Events.      Appeventslogger.activateapp (this);    }


Ps. the official website of the document to be in the onPause () also add this sentence, but measured, will error, so delete it.

Android Learning Notes Facebook SDK Preparation conditions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.