How can I open Linkedin application from my android app?

大兔子大兔子 提交于 2019-11-28 03:56:41

问题


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!


回答1:


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.




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/6101831/how-can-i-open-linkedin-application-from-my-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!