Facebook Integration in Android App


Hello Folks, In this tutorial, I’ll show you how to add facebook login in your android app.
On logging in Facebook, we’ll get the name and email of the facebook user and show it in TextView.
Lets’s get started.

CONFIGURING FACEBOOK SDK

STEP-1

Go to Facebook developer console  and login. Create a new project “AndroidLoginDemo”. Get the AppID of the project you have created.

1

STEP-2

On the same page, click on Choose Platform and select Android to add the Facebook SDK in your Android Project. This will open the quick start guide for adding Facebook SDK to Android. Follow the steps given over there.

STEP-3

For adding the development and release key hashes, download openssl if you don’t have it already and run the following command.

keytool -exportcert -alias androiddebugkey -keystore “<YOUR_DEBUG_KEYSTORE_PATH>” | “<YOUR_OPENSSL_PATH>” sha1 -binary | “<YOUR_OPENSSL_PATH>” base64

Here’s what I executed in my system to generate the key hash:

keytool -exportcert -alias androiddebugkey -keystore “C:\Users\Vivek\.android\debug.keystore” | “C:\Users\Vivek\Desktop\Cyber Lab\openssl-0.9.8k_WIN32\bin\openssl.exe” sha1 -binary | “C:\Users\Vivek\Desktop\Cyber Lab\openssl-0.9.8k_WIN32\bin\openssl.exe” base64

Capture

So, my key hash is: MjWAzIG8H9GKcq7Ul4pAE6+4AN0=

Go back to your facebook developer console and paste the above key in key hashes field.

DESIGNING THE LAYOUT

Add the following code in your activity_main.xml file.

THE REAL PART(CODE)

RUNNING THE APP

Run the app and click on Login with Facebook. Login with your credentials. You’ll see your Name and Email displayed in the textviews.

 

Screenshot_20160913-211932Screenshot_20160913-212010

 

DOWNLOAD THE COMPLETE PROJECT

Please comment below if you are having any issues. Thank you 🙂


 

admin Author

Leave a Reply

Your email address will not be published. Required fields are marked *