打开指定的个人资料页的Facebook应用程序 [英] Opening facebook app on specified profile page

查看:172
本文介绍了打开指定的个人资料页的Facebook应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一些code,从左右,但它失败:

I'm trying to use some code from SO but it fails:

这些都是URI是应该打开应用程序的右侧部分。

Those are uri's supposed to open the right section of the app.

facebook://facebook.com/info?user=544410940     (id of the user. "patrick.boos" won't work)
facebook://facebook.com/wall?user=544410940   (will only show the info if you have added it as 

我要的是开在我指定的资料档案的Facebook应用程序。这是一个code,我正在努力。数是配置文件的UID。

What I want is to open facebook app on a profile I've specified. This is a code that I'm trying. The number is UID of the profile.

        String uri = "facebook://facebook.com/wall?user=417079614970109"; 
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        startActivity(intent);

难道是去preciated还是什么?我该如何完成这样的任务呢?

Is it depreciated or what? How do I accomplish such task now?

推荐答案

其实它看起来像这样。这些URI只与最新版本的Facebook应用程序的工作。这就是为什么我们试图追赶。

Actually it looks like this. These URIs only work with the most recent version of the facebook app. That's why we try catch.

public static Intent getOpenFacebookIntent(Context context) {

    try {
        context.getPackageManager()
                .getPackageInfo("com.facebook.katana", 0); //Checks if FB is even installed.
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("fb://profile/254175194653125")); //Trys to make intent with FB's URI
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW,
                Uri.parse("https://www.facebook.com/arkverse")); //catches and opens a url to the desired page
    }
}

在你的活动,打开它,把它像这样:

In your Activity, to open it, call it like so:

Intent facebookIntent = getOpenFacebookIntent(this);
startActivity(facebookIntent);

这篇关于打开指定的个人资料页的Facebook应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆