Facebook SDK for Android

Integrating an Android app with Facebook’s platform is something that requires a great deal of patience and understanding. While allowing you to do this, Facebook SDK for Android also renders support for reading and writing to the Facebook APIs, log in with Facebook authentication and support for a set of UI elements including dialogs, pickers, etc.

And now, the steps involved in setting up Facebook SDK for Android. Hereunder is the Facebook integration in an Android step by step.

1. Install software

As the very first step, ensure that you have all the required software programs installed on your system. These include Android 2.2(API 8) platform, Facebook SDK for Android, API on Emulator( this is optional and applicable only in case you’re inclined to use the Android emulator during app development).

2. Create an app on Facebook

Before proceeding ahead to the integration of Facebook SDK into your Android app, you need to create a separate Facebook app on your Facebook developer console itself. For this, simply visit the Facebook developer console and create the new Facebook application. Once you’re done with creating the new app, you’ll receive a unique app id that would allow your app to stand out from the crowd.

3. Create an Android app

After having created a Facebook app in your Facebook developer console, gear up for importing Facebook SDK for Android to your workspace. One of the best ways of attaching the Facebook SDK is to add it as an Android library by navigating to the project’s unique properties.

4. Insert code given below

Insert the below-mentioned code before the tag in your Android application manifest file. Here, also ensure that you are using your own AppID that was obtained post the creation of an app using the Facebook developer console(this has already been explained above). In addition to the above code, also add the required tags in the manifest file, followed by adding a meta tag in the application id and declaring Facebook’s Login Activity as explained in the below code snippet:

5. Give required permissions

Finally, open a session and inquire for the user’s first name. Here, the Facebook SDK for Android will automatically prompt the user to log in and accept all the basic permissions with the help of login activity. The code related to this task is shown below: So, with that, you’re done. Well, if your Android application requires a user to log in, then it is highly recommended to integrate the same with Facebook SDK. The reason for this being that it will not only make the login process smoother but will even allow you to monetize your application in the best possible manner.

Wrapping up

Here’s hoping all the information covered in this blog would have served as a handy guide for all of you who’re thinking about equipping your Android application with some incredibly amazing features of the very popular and trendy Facebook social networking website. So, make a move and follow the above steps to attain your goal.

How to Use Facebook SDK for Android  - 87