我想在我的应用程序中打开深层链接对话框,所以我在 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>
ActivityA 和 ActivityB 使用架构,当我运行上面的代码时,它会显示如下对话框:
对话框列出了我的应用程序 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/