我希望在我的应用程序中包含Facebook的故事,这样当用户点击一篇文章时,它会在Facebook的本机应用程序中打开(如果存在)。 我已经尝试了下面的代码,但它似乎非常过时。
Intent viewIntent;
try {
getActivity().getPackageManager().getPackageInfo("com.facebook.katana", 0);
String uri = "fb://post/" + post.getId();
viewIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(uri));
} catch (Exception e) {
String url = "https://www.facebook.com/" + PAGE_ID
+ "/posts/" + post.getId;
viewIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
}
startActivity(viewIntent);