Open Facebook page from Android app?

前端 未结 26 3128
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 07:03

from my Android app, I would like to open a link to a Facebook profile in the official Facebook app (if the app is installed, of course). For iPhone, there exists the

26条回答
  •  心在旅途
    2020-11-22 07:46

    This works on the latest version:

    1. Go to https://graph.facebook.com/ (https://graph.facebook.com/fsintents for instance)
    2. Copy your id
    3. Use this method:

      public static Intent getOpenFacebookIntent(Context context) {
      
         try {
          context.getPackageManager().getPackageInfo("com.facebook.katana", 0);
          return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://page/"));
         } catch (Exception e) {
          return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"));
         }
      }
      

    This will open the Facebook app if the user has it installed. Otherwise, it will open Facebook in the browser.

    EDIT: since version 11.0.0.11.23 (3002850) Facebook App do not support this way anymore, there's another way, check the response below from Jared Rummler.

提交回复
热议问题