Nowadays, social media integration has become one of the most effective means of making an app successful. Whether it’s your social app or your business app, integrating it with a highly popular social network is perhaps the best method of reaching out to a wider group of targeted audience. Amongst the wide count of social networking websites available over the internet, Facebook has been holding the topmost position. Being the supreme social network in the world, Facebook has also found its niche in the world of social SDKs. If you’re an Android app developer, then you’d be definitely familiar with the benefits of getting started with Facebook SDK on Android. If you aren’t then don’t worry because this blog will tell you all. Here, I’ve covered some vital aspects related to the use of Facebook SDK during Android app development projects.

Facebook SDK

Facebook SDK- Features that it supports?
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 also renders support for reading and writing to the Facebook APIs, Login with Facebook authentication and support for a set of UI elements including dialogs, pickers etc.

Facebook SDK for Android

And now, the steps involved in setting up Facebook SDK for Android

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

Facebook SDK for Android - Steps

Step 2-Create an app on Facebook
Before proceeding ahead to 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.

Step 3- Now, create an Android app using Facebook SDK
After having created a Facebook app in your Facebook developer console, gear up for importing Facebook SDK 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.

Step 4-Insert the below mentioned code before the </application> 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).

<activity android:name="com.facebook.LoginActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/app_id" />

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:

<uses-permission android:name="android.permission.INTERNET"/>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="1509004692340262"/>
<activity android:name="com.facebook.LoginActivity"/>

Step 5 – Finally, open a session and inquire for the user’s first name. Here, the Facebook SDK will automatically prompt the user to login and accept all the basic permissions with the help of LoginActivity. The code related to this task is shown below:

private void openFacebookSession() {
// Open a Facebook session to get the user's name
Session.openActiveSession(this, true, new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Request.newMeRequest(session, new Request.GraphUserCallback() {
// Response Callback
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
TextView welcome = (TextView) findViewById(R.id.welcomeText);
welcome.setText("Welcome " + user.getFirstName() + "!");
}
}
}).executeAsync();
}
}
});
}

So, with that you’re done. Well, if your Android application requires a user to login 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 it all 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.

Author Bio:
juana-stevesJuana Steves is a technical writer for Xicom Ltd, that allows you Outsource Android Development Services at premium quality. Feel free to get in touch with her, in case you are willing to Hire Android App Developers for availing any app development services.