【问题标题】:How to add exception urls for action.VIEW in Android如何在 Android 中为 action.VIEW 添加异常 URL
【发布时间】:2018-02-20 03:53:44
【问题描述】:

在我的 Manifest 文件中,我确保每当单击指向我的网站的链接并使用 ACTION_VIEW 创建 Intent 时,我的应用都会向用户提供有关应使用什么打开链接的建议.他们通常可以在 Chrome 和我的应用之间进行选择。

现在,我如何添加一个我不希望我的应用打开的 URL,我只想让 chrome 立即打开它(不要求用户在 chrome 和我的应用之间进行选择)

例如,我想保留下面的代码,但修改它以排除“mywebsite.com/promotion”被我的应用打开

    <activity
        android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </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:host="mywebsite.com"
                android:scheme="http" />
            <data
                android:host="mywebsite.com"
                android:scheme="https" />
        </intent-filter>
    </activity>

编辑有人建议这里的答案可能会有所帮助:Exclude few Urls from deeplinking

但这不是因为它是针对一个非常特殊的情况,这不适用于我的情况

【问题讨论】:

标签: android edit


【解决方案1】:

不可能,intent-filter只允许指定匹配的URL(白名单),没有排除机制(黑名单)。

顺便说一句,这个问题已经回答了:How to exclude URLs with Android Intent Filters?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-06
    • 2012-11-21
    • 2017-01-05
    • 1970-01-01
    • 2013-07-22
    • 2020-02-03
    • 1970-01-01
    • 2014-09-20
    相关资源
    最近更新 更多