如何从我的Android应用程序打开Linkedin应用程序?

问题描述 投票:6回答:4

我像这样从我的Android应用程序中轻松打开Facebook和Twitter个人资料:

           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();
                        }   
                    }

但是我不知道如何打开Linkedin应用程序?有人知道Linkedin的类别名称吗?

谢谢你们!

android android-intent linkedin
4个回答
15
投票

可以使用Intents打开LinkedIn应用程序,但该API的文档(完全没有?)没有很好地记载。有效的URI是:

  • linkedin:// you
  • linkedin:// profile / [个人资料ID]
  • linkedin:// group / [group id]

所以您可以使用:

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);

一段时间以来,我一直在尝试使用意图打开公司资料,但目前还没有结果。要获取个人资料ID,只需访问个人资料页面并检查URL。要获取公司ID,请转到https://developer.linkedin.com/apply-getting-started#company-lookup


2
投票

Wieux回答了这个问题,这几乎是正确的解决方案,他只有一个错字,导致他的解决方案不起作用。由于某种原因,有人删除了Wieux的回答和我的更正。为此,我再次编写解决方案。

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

就是这样,此解决方案并不完整,因为它仅适用于人员,不适用于公司,因此我仍然不了解linkedin的所有不同形式的url。仅当您具有数字形式的memberId时,此解决方案才有效,但是应将String放入,但不要将其作为memebr id。

希望有帮助。


0
投票

在com.linked.android.profile.ViewProfileActivity类上尝试putStringExtra(“ memberId”,the_id


0
投票

仅对公司使用,Android会自动建议在LinkedIn应用程序中打开:

© www.soinside.com 2019 - 2024. All rights reserved.