2015-07-21 24 views
0

我试图应用找到的解决方案here,但我只有链接的配置文件的URL,而不是ID。该代码最终总是Ø如何在不知道配置文件ID的情况下从我的应用打开LinkedIn应用?

String username = "bill-johnson"; // this is inferred from the full URL 

public void toLinkedIn(){ 
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("linkedin://" + username)); 
     final PackageManager packageManager = getPackageManager(); 
     final List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); 
     if (list.isEmpty()) { 
       // fall back on the full URL, which I also know. 
       intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LINKEDIN_URL)); 
     } 
     startActivity(intent); 
    } 

回答

相关问题