1

我正在使用以下代码从我的 android 应用程序打开一个 facebook 页面。它使用我的 Fb 应用程序打开页面,但打开的页面并不完全是 fb 页面。它更像是关于部分。附上截图。

    public static String FACEBOOK_URL = "https://www.facebook.com/LocalPakistaniGamesAndroid/";
    public static String FACEBOOK_PAGE_ID = "LocalPakistaniGamesAndroid";
    public String getFacebookPageURL(Context context) {
        PackageManager packageManager = context.getPackageManager();
        try {
            int versionCode = packageManager.getPackageInfo("com.facebook.katana", 0).versionCode;
            if (versionCode >= 3002850) { //newer versions of fb app
                Log.d("MY","new version");
                return "fb://facewebmodal/f?href=" + FACEBOOK_URL;
            } else { //older versions of fb app
                Log.d("MY","old version");
                return "fb://page/" + FACEBOOK_PAGE_ID;
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("MY", "App not found");
            return FACEBOOK_URL; //normal web url
        }
    }

Intent facebookIntent = new Intent(Intent.ACTION_VIEW);
String facebookUrl = getFacebookPageURL(this);
facebookIntent.setData(Uri.parse(facebookUrl));
startActivity(facebookIntent);

打开页面: http://oi65.tinypic.com/33ads8h.jpg

实际页面:http://oi66.tinypic.com/2yycp6c.jpg

4

0 回答 0