android - 在我的应用程序中处理我的网站 URL

标签 android url android-manifest

我想在我的 Android 应用程序中处理我的网站 URL 例如 : 当用户在任何应用程序中点击 http://www.example.com/username

我的应用打开并显示用户名信息

我在点击 http://www.example.com 时使用此代码打开我的应用程序, 但谷歌浏览器开始了:(

 <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:host="www.example.com" android:scheme="http"></data>
                </intent-filter>
            </activity>

最佳答案

您必须将 android.intent.action.VIEWandroid.intent.category.DEFAULT 添加到 Activity 的 intent 过滤器中。

        <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:host="www.example.com" android:scheme="http"/>
        </intent-filter>

更多信息 https://developer.android.com/training/app-links/deep-linking.html#adding-filters

关于android - 在我的应用程序中处理我的网站 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48145805/

相关文章:

android - MpAndroidChart Line 第一次绘制不正确

javascript - 在 Android 应用程序中使用 JavaScript 以编程方式登录网站

java - 由于某种原因,共享偏好不起作用

java - JEdi​​torPane 显示带有 Google Docs 的原始 HTML

Facebook externalhit_uatext 机器人小写 url

android - react 原生 : How to open OS settings in Android and iOS?

node.js - 使用 express 和 mongodb 提供动态 URL

android - 使用 startInstrumentation 检测 Android 应用程序

android - 如何注册我的 Android 应用程序以打开我的自定义文件扩展名,而不是所有文件

java - "Unfortunately app has stopped"错误?