【问题标题】:How to open Facebook app on user timeline?如何在用户时间轴上打开 Facebook 应用程序?
【发布时间】:2016-05-07 02:09:13
【问题描述】:

我正在尝试从我的应用程序中打开一个 facebook 应用程序,但我需要将它转到特定用户的时间线。我可以在手机浏览器中打开它,它工作正常,但我无法在 facebook 应用程序中打开它......我知道 facebook 改变了以前的方式,我正在使用 facebook-android-sdk:4.6.0 这是我的代码:

public Intent getOpenFacebookIntent(String userId) {
        Log.e(TAG, "pid "+ userId);
        try {
            getPackageManager().getPackageInfo("com.facebook.katana", 0);
            return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + userId));

        } catch (Exception e) {
            return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/" + userId));

        }
    }

谢谢!

【问题讨论】:

    标签: java android facebook android-intent package-managers


    【解决方案1】:

    稍微改变一下

    "https://www.facebook.com/profile.php?id=" + userId
    

    试试这个。

    另外,仅供参考:https://www.facebook.com/" + userId 仅在您传递用户名而不是 userId 时才有效。

    【讨论】:

      【解决方案2】:

      唯一对我有用的代码是:

      public Intent getOpenFacebookIntent(String userId) {
              Log.e(TAG, "pid "+ userId);
      
              String facebookUrl = "https://www.facebook.com/"+userId;
              try {
                  getPackageManager().getPackageInfo("com.facebook.katana", 0);
      
                  return new Intent(Intent.ACTION_VIEW, Uri.parse("fb://facewebmodal/f?href=" + facebookUrl));
      
              } catch (Exception e) {
                  return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/app_scoped_user_id/" + userId));
      
              }
          }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-04
        相关资源
        最近更新 更多