3

I am currently in the process of creating direct intents to a selection of popular platforms in an Android app to share some text. I am currently trying to get a direct intent working with LinkedIn.

I have currently got a direct intent working for Twitter like so:

shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setClassName("com.twitter.android",
            "com.twitter.android.PostActivity"); 
shareIntent.setType("text/*");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);           
startActivityForResult(shareIntent, 9);

What I need now is the same for LinkedIn. So far I know the base package for LinkedIn after searching on the internet. That being "com.linkedin.android" (Please correct me if this is wrong). However, the key part I am missing is the name of the class that deals with sharing in the LinkedIn app. I.e. com.linkedin.android.?.

Richard Lewin
  • 1,870
  • 1
  • 19
  • 26

3 Answers3

5

I managed to find the intent by extracting the LinkedIn Manifest file from the APK.

The class name is: com.linkedin.android.home.UpdateStatusActivity

My code for anyone interested is:

if(Utils.doesPackageExist(getSherlockActivity(), "com.linkedin.android"))
{           
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setClassName("com.linkedin.android",
            "com.linkedin.android.home.UpdateStatusActivity"); 
    shareIntent.setType("text/*");
    shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);           
    startActivity(shareIntent);
}
else
{
    Toast.makeText(getSherlockActivity(), "Please install the LinkedIn app to share your result", Toast.LENGTH_LONG).show();
}

Credit to Ryszard Wiśniewski for his work on http://code.google.com/p/android-apktool/

Richard Lewin
  • 1,870
  • 1
  • 19
  • 26
  • Please note that the above code no longer works with the latest update of the LinkedIn app (April 19, 2013 update). The process above will fail and your app will force close. I have therefore changed the code to get the information from the PackageManager. Please see this SO post: http://stackoverflow.com/questions/9730243/android-how-to-filter-specific-apps-for-action-send-intent – Richard Lewin Apr 22 '13 at 09:58
  • Is there any way to load the app and send the user directly to my profile? – Si8 Aug 15 '13 at 19:13
  • @RichardLewin, Is there a way to direct open LinkedIn Share dialog as Android Gallery App open after click of linkedIn icon from Share App List., In sort, How to implement shareIntent of Linkedin. – TejaDroid May 04 '16 at 10:45
  • Instead of this: shareIntent.setClassName("com.linkedin.android", "com.linkedin.android.home.UpdateStatusActivity"); use this: shareIntent.setPackage("com.linkedin.android"); – patrickfdsouza Jun 07 '17 at 08:29
  • Hi, how can I open the app and redirect to a user profile ? in my use case the user can open another user's linkedIn link (to their profile) – Yasir Dec 25 '17 at 09:16
0

As of my writing, the new class name is:

com.linkedin.android.infra.deeplink.DeepLinkHelperActivity

So all together:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setClassName("com.linkedin.android",
        "com.linkedin.android.infra.deeplink.DeepLinkHelperActivity"); 
shareIntent.setType("text/*");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareText);           
startActivity(shareIntent);
Sean Thomas
  • 129
  • 12
0

It is com.linkedin.android.publishing.sharing.ShareActivity , you can download this app and see what is the current Activity name thats running on your phone https://play.google.com/store/apps/details?id=com.willme.topactivity ... But com.linkedin.android.publishing.sharing.ShareActivity seems its a private class and you can't access as you access Twitter

murugan
  • 94
  • 4