我在我的应用程序中使用应用程序索引,但有时它无法正确接收来自Chrome的意图.
如果我从我的生产网站打开链接,它将由chrome打开.所以我创建了一个具有相同代码的测试站点.但是,在这种情况下,我的应用程序正确打开深层链接.
我找不到任何解释,因为它在网络中使用相同的代码(但在不同的网站中)和相同的Android应用程序.
这是我的意图过滤器:
- <intent-filter android:autoVerify="true">
- <action android:name="android.intent.action.VIEW" />
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
- <data android:scheme="https" android:host="soriabus-web.appspot.com" android:pathPrefix="/" />
- </intent-filter>
这是我的按钮中的HTML代码:
- <a href="https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados/true"
- "type="button"
- role="button"
- class="btn btn-primary">
- Abrir Soria Bus
- </a>
如果我打开此地址(制作)中的链接,则会打开Play商店(链接的末尾是重定向到Google Play):
https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados
如果我在这个其他地址(测试)中打开链接,它会打开我的app correclty:
https://central-splice-128620.appspot.com/parada/1/plaza-mariano-granados
我不明白为什么链接处理不同.谢谢.
编辑:
是因为我正在关注同一网站内的链接吗?
https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados
=>
https://soriabus-web.appspot.com/parada/1/plaza-mariano-granados/playstore
解决方法
如果您在Android浏览器(Android 4.2中的默认浏览器)中进行测试,则可以正常使用.所以它似乎是Android Chrome浏览器的一个功能.
从这里提到: https://developer.chrome.com/multidevice/android/intents
从这里提到: https://developer.chrome.com/multidevice/android/intents
- And Chrome doesn’t launch an external app for a given Intent URI in the following cases.
- When the Intent URI is redirected from a typed in URL.
- When the Intent URI is initiated without user gesture.
在您的情况下,它与键入的URL相同.
如果您想从Chrome打开它,您应该尝试使用Google推荐的上述页面中的intent://语法.