php - 在 list 中声明自定义 URL 架构导致在完整的操作对话框中重复应用

标签 php android deep-linking custom-url

我想在我的应用程序中打开深层链接对话框,所以我在 list 中定义了以下内容:

<activity
    android:name=".ActivityA"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="rentaldashboard" />
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="my.site.com" />

        <data android:pathPattern=".*" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <activity
    android:name=".ActitivtyB"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="rentalreset" />
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="my.site.com" />

        <data android:pathPattern=".*" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />

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

ActivityAActivityB 使用架构,当我运行上面的代码时,它会显示如下对话框:

Complete action with

对话框列出了我的应用程序 Logo 两次。我一次只希望两个 Activity 分别打开一个 Logo 。那么知道我怎样才能让它成为可能吗?

最佳答案

如果您只有部分 url,例如 ActivityA 的 /user/news/admin 仅用于 ActivityB,那么您应该改进您的路径过滤器。顺便说一下,它们必须以斜杠开头,而且模式不是正则表达式。

如果你想支持自定义方案和 http(s) url,那么你应该使用多个 Intent 过滤器:

<activity
    android:name=".ActivityA"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="dev.worldofrental.com" />
        <data android:host="www.worldofrental.com" />

        <data android:pathPrefix="/urlredirect/getstarted" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <intent-filter>
        <data android:scheme="your.package.name"
              android:host="getstarted" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
</activity>

<activity
    android:name=".ActitivtyB"
    android:screenOrientation="portrait"
    android:theme="@style/AppBaseTheme"
    android:windowSoftInputMode="stateHidden|stateVisible" >
    <intent-filter>
        <data android:scheme="https" />
        <data android:scheme="http" />
        <data android:host="dev.worldofrental.com" />
        <data android:host="www.worldofrental.com" />

        <data android:pathPrefix="/urlredirect/resetpassword" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <intent-filter>
        <data android:scheme="your.package.name"
              android:host="resetpassword" />

        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
</activity>

一般来说,我会建议使用包名称作为方案,以确保没有其他应用程序会“窃取”您的 Intent 。

关于php - 在 list 中声明自定义 URL 架构导致在完整的操作对话框中重复应用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30339919/

相关文章:

php - 使用 Eloquent 在 Laravel 中进行内连接

php - 检查 PHP 中部分 session 变量是否为 null

java - Android更改表示时间和日期的字符串的格式

java - 数组有时无法按预期工作

javascript - HTML5/jQuery : pushState and popState - deep linking?

android - 当应用程序未安装在 android 中时,通过单击浏览器或邮件应用程序中的链接打开 Play 商店

ios - 分支io更改子域

php一页2结果

php - Mysql 按计数对子字符串列值进行排序

java - Exchange Service 泄露了 ServiceConnection、GridView Adapter