【发布时间】:2021-02-04 01:18:39
【问题描述】:
当在我的应用程序中接收到 OAuth 重定向时,Android“打开方式”菜单显示有 2 个选项,这两个选项都是我的应用程序。期望的行为是直接进入应用程序而不显示“打开方式”菜单。
在我添加了一个新的意图过滤器以从其他应用程序捕获“文本/纯文本”共享后,此问题开始发生。
这是我的意图过滤器,它们是同一活动的一部分:
<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="com.app" android:host="app" android:pathPrefix="" />
<data android:scheme="com.app" android:host="oauth" android:pathPrefix="" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
以及使用adb logcat捕获的Intent:
{act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=com.app://oauth?code=4pZliH2NrWWoypXnsBqEOjbMramW70&state=6AImyjKHt7ZhYPuk_pJjRQ flg=0x14000000 pkg=com.app cmp=android/com.android.internal.app.ResolverActivity (has extras)}
由于它们是同一活动的一部分,我认为它不会提示用户选择选项。我还假设action.VIEW 也只会匹配第一个意图。
尝试合并意图时,重定向无法完全发挥作用。而且从研究来看,似乎没有办法确定意图的优先级。
任何建议将不胜感激。谢谢!
【问题讨论】:
标签: android intentfilter