【问题标题】:How to open my android app from clicking custom URL?如何通过单击自定义 URL 打开我的 android 应用程序?
【发布时间】:2016-12-16 06:57:00
【问题描述】:

我正在构建一个 FB Messenger Bot 应用程序,我想将我的应用程序自定义 URL 发送到 Messenger 以进行回复,以便用户可以点击它来打开应用程序(该应用程序已安装在设备上)。此应用不在应用商店中,目前只是一个演示。

使用 Graph Send API,添加按钮:

https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button

我怎样才能做到这一点?当我在 url 有效负载中发送 http://www.example.com 时,它会在 WebView 中打开,而不是导航到安装我的 android 应用程序。

相同的网址 http://www.example.com 在我的应用中打开的其他应用。 (例如 gmail android 应用)

谢谢,

【问题讨论】:

    标签: android facebook bots deep-linking facebook-messenger


    【解决方案1】:

    @Suhas Bachewar,

    要从其他应用打开您的应用,您必须实现 deep-link

    请查找tutorial from here。

    以下 XML sn-p 显示了如何实现深度链接,您可能必须在清单中指定意图过滤器以进行深度链接。

    URI“yourapp://droid”和“http://www.yourapp.com/droid”都解析到这个活动。

    接受以“http://www.yourapp.com/droid”开头的 URI

    <activity
        android:name="com.yourapp.activity"
        android:label="@string/title" >
        <intent-filter android:label="@string/filter_title">
            <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="www.yourapp.com"
                  android:pathPrefix="/droid" />
            <!-- note that the leading "/" is required for pathPrefix-->
            <!-- Accepts URIs that begin with "yourapp://droid” -->
            <data android:scheme="yourapp"
                  android:host="droid" />
        </intent-filter>
    </activity>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-10
    相关资源
    最近更新 更多