Android 浏览器中的深层链接无法打开应用程序

far*_*___ 3 android

ResultPayActivity在清单中定义了意图过滤器,如下所示:

<activity android:name=".ResultPayActivity"
android:screenOrientation="portrait">
<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="sanduqcheh"  />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

我的应用程序包是:com.example.pegah_system.sanduqchehproject。此应用程序已安装。

现在我想通过这个深层链接在浏览器中调用应用程序:

intent://1#Intent;scheme=sanduqcheh;package=com.example.pegah_system.sanduqchehproject;end

但是当我在浏览器中调用 App 时无法执行,并且在 Google.com 上搜索 URL。

我已经阅读了关于此的其他问题,但我的问题没有解决。

我该如何解决这个问题?

Kat*_*hir 7

我认为这是值得一提的:

如果您在浏览器上键入链接,深层链接将不会打开您的应用。您必须点击链接才能启动您的应用

我浪费了将近一个小时试图调试一个完美的代码,后来发现问题出在我一直在输入链接上!


far*_*___ 5

我找到了解决方案。浏览器无法直接运行深层链接。例如,您可以像这样运行一个 html 文件:

<html xmlns="http://www.w3.org/1999/xhtml">
<a href="intent://123#Intent;scheme=sanduqcheh;package=com.example.pegah_system.sanduqchehproject;end">Click me</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)