Android 如何在Facebook应用程序中打开Facebook链接?

Android 如何在Facebook应用程序中打开Facebook链接?,android,Android,考虑: dataTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/app_scoped_user_id/1149231332XXXX/

考虑:

dataTextView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {

        Intent facebookIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/app_scoped_user_id/1149231332XXXX/"));
        startActivity(facebookIntent);
    }
});
但它总是在浏览器中而不是在应用程序中打开此URL。

签出(例如)

publicstaticintent openInFBApp(上下文){
试一试{
context.getPackageManager().getPackageInfo(“com.facebook.katana”,0);
返回新的意图(Intent.ACTION_视图,Uri.parse(“fb://page/”));
}捕获(例外e){
返回新的意图(Intent.ACTION\u视图,Uri.parse(“https://www.facebook.com/"));
}
}

如何获取“id”?@MehulSantoki检查此链接-。请投票:-)
public static Intent openInFBApp(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>"));
    }
}