【问题标题】:Prevent multiple intent-filters from matching for oauth redirect防止多个意图过滤器匹配 oauth 重定向
【发布时间】: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


    【解决方案1】:

    我发现了这个问题。我正在使用一个注入自己的库(AppAuth-Android)......

    删除库后,问题已解决。感谢您的建议!

    【讨论】:

      【解决方案2】:

      Check here

      您正在同一个意图过滤器中创建两个具有相同名称的方案。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-12-10
        • 1970-01-01
        • 2023-03-13
        相关资源
        最近更新 更多