从Android应用打开Facebook页面? [英] Open Facebook page from Android app?
问题描述
从我的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?
推荐答案
这是适用于最新版本:
- 转到 https://graph.facebook.com/<user_name_here >( https://graph.facebook.com/fsintents )
- 复制您的ID
-
使用此方法:
- Go to https://graph.facebook.com/<user_name_here> (https://graph.facebook.com/fsintents for instance)
- Copy your id
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不再支持这种方式,还有另一种方式,从Jared 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屋!