Open a facebook page from android app?

前端 未结 4 563
闹比i
闹比i 2020-12-30 16:20

How can I start an intent to open a Facebook application on a phone and navigate to the prefered page in Facebook?

I tried:

Intent intent = new Inten         


        
4条回答
  •  余生分开走
    2020-12-30 17:00

    try this code :

    String facebookUrl = "https://www.facebook.com/";
        try {
            int versionCode = getPackageManager().getPackageInfo("com.facebook.katana", 0).versionCode;
            if (versionCode >= 3002850) {
                Uri uri = Uri.parse("fb://facewebmodal/f?href=" + facebookUrl);
                   startActivity(new Intent(Intent.ACTION_VIEW, uri));
            } else {
                Uri uri = Uri.parse("fb://page/");
                startActivity(new Intent(Intent.ACTION_VIEW, uri));
            }
        } catch (PackageManager.NameNotFoundException e) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookUrl)));
        }
    

提交回复
热议问题