Facebook Integration in Android Application

Sep 06, 2016

prince

Android

0

Objective :

This tutorial is all about facebook integration of an android application using Android Studio and how we can login into an application using Facebook credentials. I have describe the process of integration in details step by step.

Final Output:

STEP 1: Create new project in Android Studio.

If you are new to Android Studio and don’t know how to create a new project then you should checkout our blog.

STEP 2: Steps of Facebook Integration with Android Application

2.1 Open Facebook Developer Panel

2.2 Choose the MyApps tab and click on the “Add a New App”.

2.3 select a platform to get started from dashboard of project

2.4 Create a new facebook App.

2.5 Set Package Name And Main Activity Name Into Facebook Developer Panel

2.6 Generate Android Key Hash for Facebook

If you are new and don’t know how to create a KEY HASH then you should checkout our blog.

How To Create Key Hash in Android.

2.6.1 Add Android Key Hash into Facebook Developer Panel and copy App ID.

2.7 Add Repositories

Open your android project. Add the given below line to Module-level /app/build.gradle before dependencies.

repositories {
mavenCentral()
}

2.7.1 Add compile dependency

Add the compile dependency with the latest version of the Facebook SDK in the /app/build.gradle file.

compile ‘com.facebook.android:facebook-android-sdk:4.7.0’

2.7.2 Add Facebook App Id

Add Facebook App Id in your project’s strings file and update your Android manifest file.

 

2.7.3 Add Internet Permission

Open your project’s AndroidManifest.xml file add the following.
Add internet permission by adding uses-permission element to the manifest file.

2.8.4 Add Facebook Activity In Manifest File and meta-data with Android ID.

Step: 3 Facebook Login

3.1 xml file

3.1.1 Facebook Login Button  

3.1.2 Facebook profile picture

3.1.3 Facebook show detail button for show details

After addition, your activity_main.xml file should look like this :-

3.1.3 dialog_details.xml for show pop up when click on details button

3.2 Java Class File

3.2.1 Initialize Facebook SDK

3.2.2 Register Callback With LoginButton

3.2.3 Forword Login Result To CallbackManager

3.2.4 create RequestData() method for access facebook data

Final Source code:

If you want facebook integration publically then follow below step

-Select App review

-Make Integration public yes

I hope you will find this blog post helpful while working with Facebook Login in Android Application. Let me know in comment if you have any questions regarding implement Facebook Login in Android Application. Please put a comment here and we will get back to you ASAP.

Got an Idea of Android App Development? Why are you still waiting for? Contact us now and see the Idea live soon.

Download Full Source Code FREE!!!

 

Post by prince

Leave a Reply

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