从Android应用打开Facebook页面? [英] Open Facebook page from Android app?

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

问题描述

从我的Android应用程序,我想打开一个Facebook的配置文件的官方Facebook应用程序(如果该应用程序安装,当然)的链接。对于iPhone,存在 fb:// URL方案,但是在我的Android设备上尝试相同的东西会抛出一个 ActivityNotFoundException

from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the fb:// URL scheme, but trying the same thing on my Android device throws an ActivityNotFoundException.

有没有机会在官方的Facebook应用程序中从代码打开Facebook个人资料?

Is there a chance to open a Facebook profile in the official Facebook app from code?

推荐答案

这是适用于最新版本:


  1. 转到 https://graph.facebook.com/<user_name_here >( https://graph.facebook.com/fsintents

  2. 复制您的ID

  3. 使用此方法:

  1. Go to https://graph.facebook.com/<user_name_here> (https://graph.facebook.com/fsintents for instance)
  2. Copy your id
  3. Use this method:

public static Intent getOpenFacebookIntent(Context context) {

   try {
    context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
    return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/<id_here>"));
   } catch (Exception e) {
    return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/<user_name_here>"));
   }
}


如果用户安装了这个应用,这将打开Facebook应用程序。否则,它将在浏览器中打开Facebook。

This will open the Facebook app if the user has it installed. Otherwise, it will open Facebook in the browser.

编辑:自11.0.0.11.23(3002850)起,Facebook App不再支持这种方式,还有另一种方式,从Jare​​d Rummler检查下面的回应。

since version 11.0.0.11.23 (3002850) Facebook App do not support this way anymore, there's another way, check the response below from Jared Rummler.

这篇关于从Android应用打开Facebook页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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