gpt4 book ai didi

Android 深度链接在 ADB 中有效,但在浏览器中无效

转载 作者:太空狗 更新时间:2023-10-29 13:16:47 24 4
gpt4 key购买 nike

我正在尝试向我的应用添加深层链接。我在我的一个 Activity 中添加了 2 个 Intent 过滤器,一个用于“http”方案,另一个用于我的自定义方案(我正在使用“示例”)。我根据这个 SO ( Deep-linking intent does not work ) 中的信息为每个方案添加了一个 Intent 过滤器,这样我就可以同时处理 example://testhttp://www. example.com/test 类型的链接。

这是我的 XML:

        <activity
android:name="com.myapp.myapp.SplashActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:label="Intent Filter label">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.LAUNCHER" />
<!-- Accepts URIs that begin with "http://www.example.com/test2” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/test2" />

</intent-filter>
<intent-filter android:label="Intent Filter label">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.LAUNCHER" />

<!-- Accepts URIs that begin with "example://test2” -->
<data android:scheme="example"
android:host="test2" />
</intent-filter>
</activity>

当我在 ADB 中测试时,它们正在正确加载:

adb shell am start -W -a android.intent.action.MAIN -d "example://test2" com.myapp.myapp

返回

Starting: Intent { act=android.intent.action.MAIN dat=example://test2 pkg=com.myapp.myapp }
Status: ok
Activity: com.myapp.myapp/com.app.myapp.SplashActivity
ThisTime: 357
TotalTime: 357
Complete

但是,我在浏览器中什么也得不到。当我在浏览器中尝试这个时:FF 中的“example://test2”我得到“找不到打开此链接的应用”,在 Chrome 和 native 浏览器中,它打开了新的 Google搜索“example://test2”。

当我尝试另一种样式时:“http://www.example.com/test2”,它只是尝试在所有 3 种浏览器中导航到该网页。

我正在从 Android Studio 将应用程序部署到我的手机。我还尝试生成调试 APK,将其发送到我的手机并进行安装。两者的结果相同。我做错了什么? 据我所知,我已经按照指南 ( https://developer.android.com/training/app-indexing/deep-linking.html ) 完成了这封信。 我的应用是否需要在商店中才能使用深层链接?

最佳答案

呃,我的 action 是 MAIN,而它应该是 VIEW...

<intent-filter>
<action android:name="android.intent.action.MAIN" />

...

<intent-filter>
<action android:name="android.intent.action.VIEW" />

关于Android 深度链接在 ADB 中有效,但在浏览器中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33768954/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com