Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 713
user420574 Avatar asked May 23 '11 19:05

user420574


1 Answers

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.

like image 137
philips77 Avatar answered Oct 14 '22 16:10

philips77