我需要我的 Android 应用程序在我的应用程序中运行某个 Activity,响应发送的 Intent 中的以下 Uri 数据:
如果我在我的 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/