Javatpoint Logo
Javatpoint Logo

Integrating LinkedIn API in Android App

In this tutorial, we will integrate the LinkedIn Sign-In functionality in our Android application. Implementing LinkedIn API in Android app helps users to login using LinkedIn account, share post, etc.

For integrating the LinkedIn API in our Android app, we need the LinkedIn Authentication Key (Client ID and Client Secret) and app Hash Key.

Steps to generate LinkedIn Authentication Key and APP Hash Key

1. Create LinkedIn developer account at and click on 'Create Application'.

android LinkedIn Integrating

2. Fill all the required details of Android application in 'Create a New Application' form and accept the LinkedIn API Terms of Use then click 'Submit'.

android LinkedIn Integrating

3. After submitting the application details, it generates LinkedIn Authentication Key. Now we will select the 'Default Application Permissions'. This permission authorizes to access privilege of user account. Here, we are selecting r_basicprofile, and 'r_emailaddress' and click 'Update'.

android LinkedIn Integrating
android LinkedIn Integrating

4. Now, we need the 'Hash Key' for our app. It can be generated by two different ways.

  • Using command on command prompt.



To generate the Hash Key through command prompt, it requires OpenSSL to be installed in our operating system. We can download it for Windows from and for Mac/Unix from .

  • Using the programming code in class.

For this application, we will use the programming code to generate 'Hash Key' for our application.

Now create our application and simply write the following code and run to generate our 'Hash Key'. It will show the application 'Hash Key' in Logcat.

android LinkedIn Integrating

5. Copy the 'Hash Key' from Logcat and paste it in Mobile tab of our LinkedIn application. After that click on 'Add' and 'Update'. This makes our application 'Hash Key' registered with LinkedIn API.

android LinkedIn Integrating

Example to Integrate LinkedIn Login in Android app

Let's create an example of integrating the LinkedIn log-in functionality in our Android application. After successful user log-in, it will redirect user to another activity (ProfileActivity) and display the user information.

We need to add the LinkedIn SDK for Android in our project. It can be downloaded from here

android LinkedIn Integrating

Required Permission

Add the Internet permission in AndroidMenifest.xml file.


Add the linkedin-sdk in settings.gradle file.

build.gradle (Module)

Add the compile project(path: ':linkedin-sdk') in build.gradle file.


Add the following code in activity_main.xml file. Download the recommended LinkedIn button from LinkedIn developer site and add it as the background of button.

In the class, we use the LISessionManager class which provides all functionality to create and manage the LISession object (LinkedIn session object). In the build, scope adds the 'Scope.R_BASICPROFILE' and 'Scope.R_EMAILADDRESS' to access user basic profile information and email address of LinkedIn.


Now, add the following code in activity_profile.xml file. In this activity, we will display the user information after successful login.

Add the LinkedIn API URL,first-name,last-name,email-address) in getRequest() method of APIHelper class. It will retrieve the user information on success of LinkedIn API.


android LinkedIn Integrating android LinkedIn Integrating
android LinkedIn Integrating android LinkedIn Integrating

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA