簡體   English   中英

如何從我的 android 應用程序打開 Linkedin 應用程序?

[英]How can I open Linkedin application from my android app?

我從我的 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 的 class 名稱嗎?

多謝你們!

LinkedIn 應用程序可以使用 Intents 打開,但 API 的文檔記錄不是很好(根本?)。 工作 URI 是:

  • 鏈接://你
  • linkedin://profile/[個人資料ID]
  • linkedin://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 go 到https://developer.linkedin.com/apply-getting-started#company-lookup

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

就是這樣,這個解決方案並不完整,因為它只適用於人而不適用於公司,我也仍然不了解 url 的所有不同 forms 用於linkedin。 這個解決方案只有在你有數字形式的 memberId 時才有效,你應該放 String 而不是 memebr id。

希望能幫助到你。

只需將其用於公司,android 將自動建議在 LinkedIn 應用程序中打開:

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

它在 Android 10 上為我工作

在 class com.linked.android.profile.ViewProfileActivity 上嘗試 putStringExtra("memberId", the_id )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM