[英]How to intercept all links and direct to my Android app, via both the “complete action using” and “share via” menus?
我正在尝试从应用程序中捕获链接,并将其定向到我的应用程序。 即使我已经实现了每个人建议的细节,但我还是无法使它起作用。
我的AndroidManifest.xml中包含以下意图过滤器:
<intent-filter>
<data android:scheme="http"
android:host="*"
android:pathPrefix="*" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.SEND" />
<data android:mimeType="text/plain" />
<action android:name="android.intent.action.SENDTO" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
我可以捕获共享的链接,我的应用程序会列在“共享方式”列表中,但它不会列在“使用完成操作”列表中。
我也曾尝试添加host和pathPrefix,但是它也不起作用。
有什么建议么? 先感谢您。
首先, pathPrefix
带一个前缀。 因此,您的<intent-filter>
仅支持在路径中以星号开头的URL,该URL很少(如果有)。
其次,正如OrhanC1所指出的,这应该至少是两个<intent-filter>
元素,一个用于VIEW
,一个用于SENDTO
。 实际上,您需要三个:
VIEW
+( BROWSABLE
和DEFAULT
) SEND
和SENDTO
)+ DEFAULT
MAIN
+ LAUNCHER
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.