【问题标题】:Is there any way to specify facebook-links with the HTTP protocol which opens the app (iPhone/Androdi) if installed?有没有办法使用 HTTP 协议指定 Facebook 链接,如果安装了该协议,该协议会打开应用程序(iPhone/Androdi)?
【发布时间】:2014-09-12 11:42:07
【问题描述】:

所以我知道 Facebook 应用支持fb:// URL scheme。但它是否也支持 HTTP 的 URL 方案?

我尝试过例如https://www.facebook.com/Google,当在 HTC One M8 设备上从 Chrome 中单击时,它不会产生打开应用程序的选项。所以很明显,Facebook 没有定义一个 URL 方案来匹配那个 URL。但他们可能创造了其他人?理论上,他们可以有一个方案,当子 URL 包含 /app 或其他内容时触发。

我的目标是链接到 Facebook 个人资料页面,如果已安装,则在应用程序中打开,如果未安装,则在浏览器中打开。不使用任何 Javascript。如果 facebook 定义了一个匹配任何 HTTP 协议的模式,这是可能的。

【问题讨论】:

    标签: facebook url-scheme


    【解决方案1】:

    我做了这个工作以链接到谷歌玩这个功能,将 te 协议更改为 facebook 可以工作

    public void getpro(View view) {
        final String appName = BuildConfig.APPLICATION_ID;
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName")));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id="+appName")));
        }
    }
    

    到:

    public void getpro(View view) {
        try {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("facebook://facebook.com/inbox")));
        } catch (android.content.ActivityNotFoundException anfe) {
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com")));
        }
    }
    

    【讨论】:

      【解决方案2】:

      您可以尝试使用 Intents 来实现这一点。我发现了这个:

      String uri = "facebook://facebook.com/inbox";
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
      startActivity(intent);
      

      Intent 用于在使用应用程序时调用其他应用程序。

      【讨论】:

      • 这很好,但我希望它也能在应用程序之外工作 - 从 Chrome for Android。
      猜你喜欢
      • 2012-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      相关资源
      最近更新 更多