我正在尝试从我的Android应用程序中打开一个特定的个人资料页面,在原生的Facebook应用程序中。我已经看到很多关于这个主题的答案,但目前它们都没有对我有用(可能是因为一些新版本)
现在,我正试图打开它:
public static Intent getFacebookIntent(PackageManager pm, String url ,String fbID) {
Intent intent;
try {
int versionCode = pm.getPackageInfo("com.facebook.katana", 0).versionCode;
boolean activated = pm.getApplicationInfo("com.facebook.katana", 0).enabled;
if(activated){
if ((versionCode >= 3002850)) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + url));
return intent;
} else {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/" + fbID));
return intent;
}
}else{
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
return intent;
}
} catch (PackageManager.NameNotFoundException e) {
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
return intent;
}
}
其中fbID是用户ID,url是用户图请求中的“链接”。 我试图将网址更改为特定的网址 “https://www.facebook.com/some_user_name”但不是运气。
该代码的结果是facebook应用程序打开并崩溃。 我可以通过网页链接打开它。
由于