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

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

问题描述

这是我的Andr​​oid应用程序,我想开一个链接到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应用程序从code。打开一个Facebook的个人资料?

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

推荐答案

这适用于最新的版本:

  1. 到<一个href="https://graph.facebook.com/<user_name_here">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的应用程序。否则,将在浏览器中打开实

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

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

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