Android:过滤特定 Uri 模式的 Intent

标签 android filter android-activity android-intent pattern-matching

我需要我的 Android 应用程序在我的应用程序中运行某个 Activity,响应发送的 Intent 中的以下 Uri 数据:

http://www.example.com/redirect.aspx?customurl=example%3a%2f%2f%3fop%3dexampledetail%26stuff%3d12345%26morestuff%3dI%2520Love%25Android

如果我在我的 list 中使用以下内容(对于我想要响应 Intent 的 Activity ),我可以捕获它,但会弹出选择器(我不想要):

<intent-filter>
 <action android:name="android.intent.action.VIEW" />
 <data android:scheme="http" android:host="www.example.com" />
 <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

因为我不想弹出选择器,所以我尝试在标签中使用 android:pathPattern 或 android:pathPrefix 来进一步过滤,以确保只有我的应用响应但它对我不起作用.

谁能帮我做这个?

最佳答案

If I use the following in my manifest (for the Activity that I want to respond to the Intent), I can capture this, but the chooser pops up (which I don't want):

大多数 Android 设备上都有 1 个以上的浏览器。非常欢迎用户在这些浏览器之一而不是您的应用程序中访问该 URL,这就是选择器出现的原因。此外,如果开发人员能够劫持他们想要的任何 HTTP URL,那将是一个巨大的安全漏洞。

现在,如果您拥有此 URL 链接到的网站,您可以使用条形码扫描器使用的技巧:使用浏览器检测在该页面上放置智能,如果在 Android 浏览器中查看,则向用户解释为什么他们应该允许您的应用程序在将来处理该 URL。

关于Android:过滤特定 Uri 模式的 Intent ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4110515/

相关文章:

android - 在 Android 11 中无法使用 taskAffinity 进行跨应用程序 Activity

android 蓝牙连接失败(isSocketAllowedBySecurityPolicy 开始 : device null)

java - Android retrofit2 通过 jackson 发送 json

c# - 如何停止默认动画?

web-applications - 如何为高流量 webapp 实现 'saved search' 功能?

android - 按下后退时如何不破坏当前 Activity

java - 在 Web 服务中使用 OAuth 时出现异常

mongodb - 获取 MongoDB 文档 WHERE 状态和日期之间

asp.net-web-api - 有没有办法通过属性而不是注入(inject)来使用 AutoFac Web Api 授权过滤器?

java - 检查一个 Activity 是否与另一个 Activity 处于 Activity 状态