Post navigation

How to Integrate Facebook in your Android App

Social media integration is one of the most important modes of OAuth for any App. Recently we have been getting a lot of queries on ‘how to integrate Facebook with Apps’. To resolve these queries we have created a sample Android App and below mentioned are the steps to integrate Facebook with this App.

1. This application shows how we can integrate an Android App with Facebook API.
2. The sample shows how we can get our Facebook friends to increase the online presence.

Running Sample:

1. First of all download Facebook SDK from here .
2. Create a Facebook application here to get a Facebook APP ID for your application.
3. You need to create a key hash of your signature from android debug.keystore (for the development stage).
4. For this First download OpenSSL from here and extract to a folder (in my case, c:\openssl) and follow these steps.

5. Download the project from here and import it in the eclipse.
6. Import Facebook SDK project in your eclipse (which you have downloaded in step 1) and make it a library project.
7. Add this library project into your sample android application.
8. Open Constants.java file and change FB_APP_ID variable value with your FB APP ID.
9. Build your android application and install on your android device.

Design Details:

Authorization With Facebook: To use Facebook API in your android application you have to authorize application. As a sample I have authorized my application in FacebookService.java file. In this method you have to pass following three parameters :

1. Your host Activity on which you have to get callback from Facebook API.
2. All Facebook API permissions required for your application in form of String array.(in this sample I had requested for friends_online_presence).
3. This is called only the first time after installation with Facebook.
4. Once your application is authorized , you can use Facebook API directly.