[英]Android deep links - Multiple re-direct with same url
在我的應用程序中,我使用深層鏈接導航到特定活動。 我想導航到具有相同 basePrefix 且最后具有不同上下文路徑的不同活動。
<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:scheme="https"
android:host="www.mycompany.com"
android:pathPrefix="/profile/friendslist"/>
</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:scheme="https"
android:host="www.mycompany.com"
android:pathPrefix="/profile/friendslist/details"/>
</intent-filter>
./adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://www.mycompany.com//profile/friendslist" com.mycompany.sample: 它啟動好友列表片段
./adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://www.mycompany.com//profile/friendslist/details" com.mycompany.sample:它還啟動 FriendsListFragment 而不是 FriendsListDetailsFragment
我想做的是
/profile/friendslist/: 應該打開FriendsList
/profile/friendslist/details?id=1234應該導航到 FriendDetails
有人建議我們如何使用 android:pathPrefix 根據上下文路徑導航到不同的屏幕嗎?
您可以在第一個intent-filter
中選擇pathPattern
<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:scheme="https"
android:host="www.mycompany.com"
android:pathPattern="/profile/friendslist$"/>
</intent-filter>
$表示字符串結尾,這將刪除“/profile/friendslist/details”案例
或者更確切地說, go for android:path="/profile/friendslist"
尋找完全匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.