How can I open Linkedin application from my android app?
Asked Answered
E

4

8

I open facebook and twitter profile easily from my android application like this:

           if (facebookId != null)
                    {
                        try
                        {
                            long longFacebookid = Long.parseLong(facebookId);

                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.setClassName("com.facebook.katana", "com.facebook.katana.ProfileTabHostActivity");
                            intent.putExtra("extra_user_id", longFacebookid);

                            startActivity(intent);

                            return;
                        }
                        catch (ActivityNotFoundException e)
                        {                       
                            e.printStackTrace();
                        }
                        catch (NumberFormatException e)
                        {   
                            e.printStackTrace();
                        }   
                    }

But I don't know how open linkedin application? Does somebody know the class name of Linkedin?

Thanks guys!

Eleni answered 23/5, 2011 at 19:17 Comment(0)
F
17

The LinkedIn app may be opened using Intents, but the API is not very well (at all?) documented. The working URIs are:

  • linkedin://you
  • linkedin://profile/[profile id]
  • linkedin://group/[group id]

So you may use:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("linkedin://you"));
final PackageManager packageManager = getContext().getPackageManager();
final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (list.isEmpty()) {
    intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.linkedin.com/profile/view?id=you"));
}
startActivity(intent);

I'm trying to open a company profile using intents since some time but no result yet. To obtain the profile id just visit the profile page and check the URL. To get the company id go to https://developer.linkedin.com/apply-getting-started#company-lookup.

Forster answered 27/5, 2014 at 8:59 Comment(4)
Thank you dude, it is working, and i have a doubt , if i dont know the app app urls how to find out them?Sukiyaki
I've downloaded the LinkedIn APK, decompiled it, checked the AndroidManifest.xml file for URLs and checked how they work by creating a very simple app that just starts an intent.Forster
This solution recently stopped working, any idea why?Hypsography
To open company profile, i have preffered to use that "linkedin://company=<Company User Name>" format.Oba
R
3

Wieux answered to this question was almost the right solution, he only had a typo that caused his solution not to work. From some reason somebody deleted Wieux's answer, and my correction. Therefor I'm writing the solution again.

Intent linkedinIntent = new Intent(Intent.ACTION_VIEW);
linkedinIntent.setClassName("com.linkedin.android", "com.linkedin.android.profile.ViewProfileActivity");
linkedinIntent.putExtra("memberId", <member id>);
startActivity(linkedinIntent);

That is it, this solution is not complete, since it work only for people and not for companies, I also still don't understand all the different forms of url for linkedin. This solution would work only if you have the memberId in the form of number, you should put String though and not long as the memebr id.

Hope it helps.

Rivet answered 1/11, 2011 at 8:22 Comment(3)
Also keep in mind that if the user is not yet logged into his account on the linkedin app that the linkedin app will crash when executing this intent!!Abohm
Thanks for the enhancement, I didn't test this scenario.Rivet
FATAL EXCEPTION: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.linkedin.android/com.linkedin.android.profile.ViewProfileActivity}; have you declared this activity in your AndroidManifest.xml?Brethren
C
1

Simply use this for a company, android will automatically suggest to open in LinkedIn app :

    startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.linkedin.com/company/your_company_id/")));

It's working for me on Android 10

Condemnatory answered 10/4, 2020 at 9:29 Comment(0)
C
0

Try putStringExtra("memberId", the_id) on the class com.linked.android.profile.ViewProfileActivity

Counterinsurgency answered 23/5, 2011 at 23:20 Comment(1)
java.lang.SecurityException: Permission Denial: starting Intent { cmp=com.linkedin.android/.profile.ViewProfileActivity (has extras) } from ProcessRecord{44c598a8 31483:com.branchu1/10058} (pid=31483, uid=10058) requires nullEleni

© 2022 - 2024 — McMap. All rights reserved.