JSt*_*hen 12 android deep-linking
我能找到的最接近的就是这个问题在这里.但它并没有完全覆盖我的问题.
我的应用设置中有深层链接,使用/ app作为路径前缀.我遇到的问题是类似http://example.com/upgrade的链接也试图在我的应用程序中打开,即使它在网址中没有/ app.我明白你不能排除前缀指定的网址,但不是只包含那些网址的路径前缀的整点?
基本上我想要像这样的链接深层链接:
http://example.com/app/home
http://example.com/app/specials
Run Code Online (Sandbox Code Playgroud)
但不是这样的链接:
http://exaple.com/
http://example.com/login
Run Code Online (Sandbox Code Playgroud)
这是我在我的清单中所拥有的:
<data android:scheme="http"
    android:host="example.com"
    android:pathPrefix="/app"/>
Run Code Online (Sandbox Code Playgroud)
编辑1
也找到了这个链接,但我没有任何空前缀,只有一个斜线"/"
编辑2
触发它的网址是http://example.com/upgrade.php?app=1&method=1&uid=1,我不确定应用程序之后是否?也会触发它所以我将前缀更改为/ application但是也没有用,它仍然触发它们.
编辑3
以下是清单中的其他深层链接数据标记:
资料活动
<data android:scheme="myapp"
    android:host="profile"
    android:pathPrefix="/"/>
Run Code Online (Sandbox Code Playgroud)
登录/注册活动
<data android:scheme="myapp"
     android:host="login"
     android:pathPrefix="/signup"/>
Run Code Online (Sandbox Code Playgroud)
主要活动
<data android:scheme="myapp"
     android:host="main"
     android:pathPrefix="/"/>
<data android:scheme="http"
     android:host="test.example.com"
     android:pathPrefix="/app"/>
<data android:scheme="http"
     android:host="live.example.com"
     android:pathPrefix="/app"/>
Run Code Online (Sandbox Code Playgroud)
编辑4
这变得越来越混乱,如果我从活动中删除myapp作为方案的数据标记(或者如果我从前缀为"/"的所有内容中删除pathPrefix)它不再触发来自web urls的深层链接,即使他们有/ app.
JSt*_*hen 10
我想通了,似乎数据标签彼此流血,所以带有方案"example"的数据上的"/"前缀也适用于其他数据标签中的所有方案.我只需要为我的自定义方案深层链接和url深层链接使用单独的Intent过滤器,如下所示:
<activity android:name=".MainActivity">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- must start with http://test.example.com/app -->
        <!-- http://test.example.com/ won't work since prefix / is in a different intent-filter -->
        <data android:scheme="http"
            android:host="test.example.com"
            android:pathPrefix="/app"/>
        <!-- must start with http://test.example.com/app -->
        <data android:scheme="http"
            android:host="live.example.com"
            android:pathPrefix="/app"/>
    </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" />
        <!-- must start with example://main/ -->
        <!-- http://test.example.com/ won't work since http is in a different intent-filter -->
        <data android:scheme="example"
            android:host="main"
            android:pathPrefix="/"/>
    </intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           8235 次  |  
        
|   最近记录:  |