The main objective of this post is to help you understand how to connect with Linkedin in Android.


You will get Final Output:

  • linkedin connectivity tutorial
  • android linkedin connectiviy demo
  • android linkedin connectiviy
  • android linkedin connection

Step 1 Create application from LinkedIn developer account.

Create application from your LinkedIn developer account. And copy paste ClientID and ClientSecrete to CONSUMER_KEY and CONSUMER_SECRET variable of Constant class.

If you don’t have developer account you can create your developer account from bellow link:


Step 2 Collect .jar files

First we need following .jar files:

  • commons-codec-1.3.jar
  • linkedin-j-android.jar
  • signpost-core-

Download it from the given link:


Step 3 Add .jar files

Add all three jar files to your Android Project to the following path ProjectName >> libs


Step 4 file

Now Start Coding for the Linkedin API Create new class file named

Put following code into class:

public class Constants 
public static final String CONSUMER_KEY = "xxxxxxxx"; // your KEY
public static final String CONSUMER_SECRET = "xxxxxxxx"; // your SECRET
public static final String OAUTH_CALLBACK_SCHEME = "x-oauthflow-linkedin";     
public static final String OAUTH_CALLBACK_HOST = "litestcalback";     
public static final String OAUTH_CALLBACK_URL =

Step 5 file

Then open your file.

Put following details into your class:

private LinkedInOAuthService oAuthService;
private LinkedInApiClientFactory factory;
private LinkedInRequestToken liToken;
private LinkedInApiClient client;

Put following code into your onCreate() method:

if (android.os.Build.VERSION.SDK_INT > 9) {
   StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()

Button btnLinkedinMain = (Button) findViewById(;


Step 6 onClick() method

Now Override onNewIntent() method into your Activity.

public void onClick(View v) 

   if (v.getId() == {

      oAuthService = LinkedInOAuthServiceFactory.getInstance()
      System.out.println("oAuthService : " + oAuthService);

      factory = LinkedInApiClientFactory.newInstance(
            Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);

      liToken = oAuthService
      Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(liToken


Step 7 onNewIntent() method

Now Override onNewIntent() method into your Activity.

try {
} catch (NullPointerException e) {

Step 8 AndroidManifest.xml file

Open your AndroidManifest.xml file.

Add following Permission:

android:launchMode="singleInstance" >             

<action android:name="android.intent.action.MAIN" />               
<category android:name="android.intent.category.LAUNCHER" />             

<action android:name="android.intent.action.VIEW" />               
<category android:name="android.intent.category.DEFAULT" />                 
<category android:name="android.intent.category.BROWSABLE" />                    
<data android:host="litestcalback"  // same as "OAUTH_CALLBACK_HOST" android:scheme="x-oauthflow-linkedin"/> 
// same as "OAUTH_CALLBACK_SCHEME"           



When you got Network Provider Exception then put the following code into your Main Activity in onCreate() method


Step 9 StrictMode.ThreadPolicy

StrictMode.ThreadPolicy was introduced since API Level 9 and the default thread policy had been changed since API Level 11, which in short, does not allow network operation (include HttpClient and HttpUrlConnection) get executed on UI thread. if you do this, you get NetworkOnMainThreadException.

This restriction can be changed, using:

if (android.os.Build.VERSION.SDK_INT > 9) {StrictMode.ThreadPolicy policy = new 

Reference Links:

I hope you enjoy this tutorial and it would be helpful to you. you can download the Full Project from GitHub.

Got an Idea of Android App Development? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Android App Development Company in India.

An entrepreneur who has founded 2 flourishing software firms in 7 years, Tejas is keen to understand everything about gaming - from the business dynamics to awesome designs to gamer psychology. As the founder-CEO of a company that has released some very successful games, he knows a thing or two about gaming. He shares his knowledge through blogs and talks that he gets invited to.