Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在android中使用intent打开Linkedin配置文件_Android_Android Intent_Linkedin - Fatal编程技术网

无法在android中使用intent打开Linkedin配置文件

无法在android中使用intent打开Linkedin配置文件,android,android-intent,linkedin,Android,Android Intent,Linkedin,如何使用intent打开linkedin配置文件: 我的代码: context.getPackageManager().getPackageInfo(APP_PACKAGE_NAME, 0); intent = new Intent(Intent.ACTION_VIEW, Uri.parse("linkedin://profile/" + profileID)); intent.setPackage(APP_PACKAGE_NAME); // intent.add

如何使用intent打开linkedin配置文件:

我的代码:

context.getPackageManager().getPackageInfo(APP_PACKAGE_NAME, 0);
                intent = new Intent(Intent.ACTION_VIEW, Uri.parse("linkedin://profile/" + profileID));
intent.setPackage(APP_PACKAGE_NAME);
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
日志:

Uri.parse(“linkedin://you"));
最终PackageManager PackageManager=getContext().getPackageManager();
最终列表列表=packageManager.QueryInputActivities(仅适用于意图、packageManager.MATCH\u默认值);
if(list.isEmpty()){
intent=新的intent(intent.ACTION\u视图,Uri.parse(“http://www.linkedin.com/profile/view?id=you"));
}
星触觉(意向);
基于最新版本,您应该使用
DeepLinkHelper
将深度链接与官方应用程序集成:

// Get a reference to an activity to return the user to
final Activity thisActivity = this;

// A sample member ID value to open
final String targetID = "abcd1234";

DeepLinkHelper deepLinkHelper = DeepLinkHelper.getInstance();

// Open the target LinkedIn member's profile
deepLinkHelper.openOtherProfile(thisActivity, targetID, new DeeplinkListener() {
    @Override
    public void onDeepLinkSuccess() {
        // Successfully sent user to LinkedIn app
    }

    @Override
    public void onDeepLinkError(LiDeepLinkError error) {
        // Error sending user to LinkedIn app
    }
});
或者选择以下选项打开当前已验证用户的配置文件:

// Get a reference to an activity to return the user to
final Activity thisActivity = this;

DeepLinkHelper deepLinkHelper = DeepLinkHelper.getInstance();

// Open the current user's profile
deepLinkHelper.openCurrentProfile(thisActivity, new DeeplinkListener() {
    @Override
    public void onDeepLinkSuccess() {
        // Successfully sent user to LinkedIn app
    }

    @Override
    public void onDeepLinkError(LiDeepLinkError error) {
        // Error sending user to LinkedIn app
    }
});
无论哪种方式,如果深入研究,你会发现它最终构建了打开LinkedIn应用程序的
意图,如下所示:

private void deepLinkToProfile(@NonNull Activity activity, String memberId, @NonNull AccessToken accessToken) {
    Intent i = new Intent("android.intent.action.VIEW");
    Uri.Builder uriBuilder = new Uri.Builder();
    uriBuilder.scheme("linkedin");
    if (CURRENTLY_LOGGED_IN_MEMBER.equals(memberId)) {
        uriBuilder.authority(CURRENTLY_LOGGED_IN_MEMBER);
    } else {
        uriBuilder.authority("profile").appendPath(memberId);
    }
    uriBuilder.appendQueryParameter("accessToken", accessToken.getValue());
    uriBuilder.appendQueryParameter("src", "sdk");
    i.setData(uriBuilder.build());
    Log.i("Url: ", uriBuilder.build().toString());
    activity.startActivityForResult(i, LI_SDK_CROSSLINK_REQUEST_CODE);
} 
如您所见,除其他事项外,它将访问令牌附加到
Uri
,作为带有key
accessToken
的查询参数。添加的另一个查询参数是
src
,它(大概)只是用于统计目的,而不是功能性的

现在,如果查看错误日志中的这一行:

E/com.linkedin.android.deeplink.helper.LaunchHelper﹕ urlParams was null, indicating a failure to validate the path in getMap()
注:

urlParams为空

对我来说,这听起来像是期望为数据
Uri
提供一个或多个查询参数。我倾向于说,这很可能是指(至少)您自己的代码片段中缺少的
accessToken
查询参数,但它是SDK流的一部分

希望这是朝着正确的方向推进。只使用LinkedIn SDK可能是最简单的,有什么特别的原因吗

const string PACKAGE = "com.linkedin.android";
Intent intent = new Intent(Intent.ActionView, Uri.Parse("https://www.linkedin.com/in/danielroberts0"));
if(isPackageInstalled(Forms.Context, PACKAGE)) {
    intent.SetPackage(PACKAGE);
}
Forms.Context.StartActivity(intent);
没有一个解决方案提供了我所需要的——在应用程序中打开用户配置文件页面。默认情况下或其他情况下

参考:

公共无效openLinkedInPage(字符串linkedId){
Intent Intent=新的Intent(Intent.ACTION\u视图,Uri.parse(“linkedin://add/%@“+);
最终PackageManager PackageManager=getContext().getPackageManager();
最终列表列表=packageManager.QueryInputActivities(仅适用于意图、packageManager.MATCH\u默认值);
if(list.isEmpty()){
intent=新的intent(intent.ACTION\u视图,Uri.parse(“http://www.linkedin.com/profile/view?id=“+);
}
星触觉(意向);
}

尝试此操作,它将在应用程序中打开LinkedIn配置文件,或者在浏览器中打开,如果未安装LinkedIn应用程序(从2018年11月起生效,使用最新版本的LinkedIn应用程序),则无需使用
DeepLinkHelper

        String profile_url = "https://www.linkedin.com/in/syedfaisal33";
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(profile_url));
            intent.setPackage("com.linkedin.android");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } catch (Exception e) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(profile_url)));
        }

当你说“在配置文件中打开链接”时,你在哪里以及如何打开它?方法在另一个类中,我在其中编写代码打开linkedin配置文件,我在单击时调用该方法。我不太确定,但你是否试图传递一个url以及意图?意思是?我不明白你在说什么我已经发布了我正在做的事情。所以现在你有不同的问题了?看起来您可能需要先阅读一篇文章(特别是从底部往下读)。如果您的代码发生了根本性的变化,您是否可以用您当前的问题更新您的问题,或者开始一个新的问题?如果您想在LinkedIn应用程序和浏览器之间进行选择,请使用此代码,而不是第三行,
Intent Intent=new Intent(Intent.ACTION\u视图,Uri.parse(“linkedin://syedfaisal33"));
const string PACKAGE = "com.linkedin.android";
Intent intent = new Intent(Intent.ActionView, Uri.Parse("https://www.linkedin.com/in/danielroberts0"));
if(isPackageInstalled(Forms.Context, PACKAGE)) {
    intent.SetPackage(PACKAGE);
}
Forms.Context.StartActivity(intent);
public void openLinkedInPage(String linkedId) {
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("linkedin://add/%@" + linkedId));
        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=" + linkedId));
        }
        startActivity(intent);
    }
        String profile_url = "https://www.linkedin.com/in/syedfaisal33";
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(profile_url));
            intent.setPackage("com.linkedin.android");
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        } catch (Exception e) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(profile_url)));
        }
fun getOpenLinkedin(context: Context, url: String) {
    val linkedinIntent = Intent(Intent.ACTION_VIEW)
    linkedinIntent.setClassName("com.linkedin.android", "com.linkedin.android.profile.ViewProfileActivity")
    linkedinIntent.putExtra("memberId", "profile")
    linkedinIntent.setPackage("com.linkedin.android")
    try {
        context.startActivity(linkedinIntent)
    } catch (e: ActivityNotFoundException) {
        context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url)))
    }
}