简体   繁体   中英

How can I open Linkedin application from my android app?

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!

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 .

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM