2011-05-23 138 views
3

我輕易打開Facebook和Twitter的個人資料從我的Android應用程序是這樣的:如何從我的android應用程序中打開LinkedIn應用程序?

  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的類名嗎?

謝謝你們!

回答

0

的類com.linked.android.profile.ViewProfileActivity

+0

兩者都不起作用 – user420574 2011-05-24 12:26:32

+0

從ProcessRecord {44c598a8 31483:com.branchu1 /}啓動Intent {cmp = com.linkedin.android/.profile.ViewProfileActivity(還有額外功能)}:java.lang.SecurityException:Permission Denial: 10058}(pid = 31483,uid = 10058)要求爲空 – user420574 2011-05-24 12:29:38

0

Wieux回答這個問題幾乎是正確的解決方案嘗試putStringExtra(「成員」,the_id),他只有引起他的解決方案不是一個錯字上班。由於某種原因,有人刪除了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。這個解決方案只有在你有number的形式的memberId時才能工作,你應該把字符串儘管並且不要和memebr ID一樣長。

希望它有幫助。

+2

另外請記住,如果用戶尚未登錄LinkedIn應用程序中的賬戶,linkedin應用程序將在執行此意圖時崩潰! – Jeroen 2012-09-12 12:09:38

+0

感謝您的加強,我沒有測試這種情況。 – nheimann1 2012-09-30 13:43:35

+0

**致命異常**:android.content.ActivityNotFoundException:無法找到顯式活動類{com.linkedin.android/com.linkedin.android.profile.ViewProfileActivity}; *你是否在你的AndroidManifest.xml中聲明瞭這個活動?* – PLNech 2015-09-23 19:50:00

11

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

  • LinkedIn://你
  • LinkedIn://資料/ [簡介ID]
  • LinkedIn://組/ [組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。 要獲得公司編號,請轉至https://developer.linkedin.com/apply-getting-started#company-lookup

+0

謝謝你,他正在工作,我有疑問,如果我不知道應用程序的應用程序urls如何找出它們? – Thamaraiselvam 2015-02-02 08:50:13

+0

我已經下載LinkedIn APK,反編譯它,檢查AndroidManifest.xml文件中的URL,並通過創建一個非常簡單的應用程序來檢查它們的工作方式,只是開始一個意圖。 – philips77 2015-02-03 11:44:39

+0

這個解決方案最近停止了工作,任何想法爲什麼? – 2015-11-30 11:10:08

相關問題