android - 深度链接中的Android路径模式
问题描述
我正在尝试在我的应用程序中建立一个深层链接。我需要支持的路径模式看起来像
URL:www.host.com/somestring-<2letters>/ 示例:好 URL:www.host.com/Portland-OR/ 坏 URL:www.host.com/Portland-、www.host.com/-或, www.host.com/-, www.host.com/Por-O
所以我有一组至少 1 个字符或更长的字母数字字符集。然后我有一个“-”,然后是 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="http" android:host="host.com" android:pathPrefix="/.*-.*/" />
</intent-filter>
我也阅读了以下文档及其周围的源代码。 https://developer.android.com/reference/android/os/PatternMatcher
任何帮助将不胜感激。谢谢!
解决方案
您不能以静态方式执行此操作,但您可以在您的或任何组件包含的AndroidManifest.xml
代码中编写您自己的编程模式匹配器,方法是通过使用正则表达式提取实例,或者只是按字符拆分并检查第二部分。<activity>
<intent-filter>
Uri
intent.getData()
-
推荐阅读
- php - 如何正确设置 PHP while 循环而不重复重复数据
- excel-formula - 试图在 Excel 中将产品零件与最终装配相加
- python - 如何在 for 循环中命名数据帧?
- highcharts - 在高图表上悬停时围绕轴的环可变半径饼图
- php - ErrorException 试图获取非对象 laravel 的属性
- c++ - 如何制作构造函数的深层副本
- node.js - 使用 Reactjs 应用程序作为域后端中 express nodejs 的前端
- html - SVG 徽标无法在移动设备上正确显示
- python - 为 RabbitMQ 保持打开连接还是仅在必要时打开连接更好?
- react-native - 捕获新视频时如何不捕获设备上运行的音频播放