android - 在 android 中打开与 facebook 应用程序的链接

标签 android facebook

请参阅下面的两个链接。在 Whatsapp 中粘贴时,第一个使用 Facebook 应用程序打开,但第二个使用浏览器打开。

在 Facebook 应用程序中打开:

https://m.facebook.com/SriSwamiji/posts/1099353043449548:0

在浏览器中打开:

https://www.facebook.com/SriSwamiji/photos/a.186720728046122.67368.108460819205447/1099353043449548/?type=3

是什么让第二个链接在浏览器中打开? 我想通过 Facebook 应用打开它。

最佳答案

我会说这是由于 deep linking .在您的任何应用中,您都可以添加过滤器,以便在 Android 系统尝试解析 URL 时触发您的应用。

可能 Facebook 应用程序配置了 http://m.* url 的深层链接

编辑:我已经通过 adb 对其进行了测试,这是由于深层链接。你可以测试它

adb shell am start -W -a android.intent.action.VIEW -d <URL>

the deep link documentation 中所述

这是输出:

$ adb shell am start -W -a android.intent.action.VIEW -d "https://m.facebook.com/SriSwamiji/posts/1099353043449548:0"
Starting: Intent { act=android.intent.action.VIEW dat=https://m.facebook.com/... }
Status: ok
Activity: com.facebook.katana/com.facebook.deeplinking.activity.StoryDeepLinkLoadingActivity
ThisTime: 127
TotalTime: 208
WaitTime: 253
Complete

如您所见,启动的 Activitycom.facebook.katana(Facebook 应用程序)。

$ adb shell am start -W -a android.intent.action.VIEW -d "https://www.facebook.com/SriSwamiji/photos/a.186720728046122.67368.108460819205447/1099353043449548/?type=3"
Starting: Intent { act=android.intent.action.VIEW dat=https://www.facebook.com/... }
Status: ok
Activity: com.android.chrome/org.chromium.chrome.browser.document.DocumentActivity
ThisTime: 121
TotalTime: 179
WaitTime: 223
Complete

在这种情况下 com.android.chrome 被启动

此外,如果您查看 Facebook 应用程序 list (使用像 ManifestViewer 这样的应用程序,您可以看到它有一些 intent-filter 来处理它:

        <intent-filter>
            <action
                android:name="android.intent.action.VIEW"/>
            <category
                android:name="android.intent.category.DEFAULT"/>
            <category
                android:name="android.intent.category.BROWSABLE"/>
            <data
                android:scheme="http"
                android:host="m.facebook.com"
                android:pathPrefix="/events"/>
            <data
                android:scheme="https"
                android:host="m.facebook.com"
                android:pathPrefix="/events"/>
            <data
                android:scheme="http"
                android:host="m.facebook.com"
                android:pathPrefix="/groups"/>
            <data
                android:scheme="https"
                android:host="m.facebook.com"
                android:pathPrefix="/groups"/>
            <data
                android:scheme="http"
                android:host="www.facebook.com"
                android:pathPrefix="/groups"/>
            <data
                android:scheme="https"
                android:host="www.facebook.com"
                android:pathPrefix="/groups"/>
            <data
                android:scheme="http"
                android:host="www.facebook.com"
                android:pathPrefix="/events"/>
            <data
                android:scheme="https"
                android:host="www.facebook.com"
                android:pathPrefix="/events"/>
        </intent-filter>

在您的具体情况下,我会说该链接是在

中处理的
    <activity
        android:theme="@2131625627"
        android:name="com.facebook.katana.ContactUriHandler"
        android:taskAffinity="com.facebook.task.ContactUriHandler"
        android:excludeFromRecents="true"
        android:launchMode="singleInstance">
        <intent-filter>
            <action
                android:name="android.intent.action.VIEW"/>
            <category
                android:name="android.intent.category.DEFAULT"/>
            <data
                android:mimeType="vnd.android.cursor.item/vnd.facebook.profile"
                android:host="com.android.contacts"/>
            <data
                android:mimeType="vnd.android.cursor.item/vnd.facebook.presence"
                android:host="com.android.contacts"/>
        </intent-filter>
    </activity>

内部支持帖子但不支持照片

关于android - 在 android 中打开与 facebook 应用程序的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35377211/

相关文章:

ruby-on-rails - omn​​iauth-facebook 无法获取电子邮件地址

java - 使用 RestFB 仅获取 Facebook 的最新帖子

iOS : Login with Facebook and open Native Facebook app

android - 在android中录制时如何保持音频大小,减少?

android - 在 Xamarin Android 中实现电话调用服务

android - 如何实现应用服务器

android - 在 "fluid way"中使用共享 Intent

javascript - Facebook API 实现

android - Android 对话框内的 VideoView Completion Listener

Android 登录按钮不调用 onActivityResult 或回调方法