【发布时间】:2014-06-24 05:58:01
【问题描述】:
我正在尝试使用特定用户 ID 在我的 android 应用中打开某些 Facebook 个人资料页面。 如果已安装,我的代码将打开 facebook 应用程序,否则打开 webbrowser。 它工作正常,除非安装了 facebook 应用程序并关闭它。 在这种情况下,它只会打开新闻源页面而不是个人资料页面。当 facebook 应用程序在后台打开时,它会成功重定向到所需的个人资料页面。我该如何解决这个问题?还有一个官方的 facebook 文档描述了访问 facebook 应用程序 URI 的方式吗?
try{
this.getPackageManager()
.getPackageInfo("com.facebook.katana", 0); //Checks if FB is even installed.
final String facebookScheme = String.format("fb://profile/%s", user2FbID);
final Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
facebookIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY
| Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(facebookIntent);
}catch (Exception e) {
String facebookScheme = "https://m.facebook.com/" + user2FbID;
Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(facebookScheme));
startActivity(facebookIntent);
}
【问题讨论】:
标签: android facebook facebook-graph-api