android - 我想在我的设备上创建一个应用程序的链接,但它不工作
问题描述
我想在我的设备上创建一个应用程序的链接(该应用程序不是我的,所以我无法编辑它)。我发现它有一个看起来像这样的意图过滤器。
<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:host="ravkavonline.co.il"
android:pathPrefix="/pos/" android:scheme="https"/>
</intent-filter>
我写了以下链接
<a href="https://ravkavonline.co.il">click me!</a>
但它在浏览器中将我发送到他们的网站,而不是打开应用程序。
解决方案
您必须在单击后必须重定向的特定活动上添加意图过滤器
<activity
android:name=".ui.SplashActivity"
android:screenOrientation="portrait"
android:exported="true">
<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="http"
android:host="www.xyz.com"
android:pathPrefix="/"/>
</intent-filter>
您必须在活动类中添加此行
Intent appLinkIntent = getIntent();
String appLinkAction = appLinkIntent.getAction();
Uri appLinkData = appLinkIntent.getData();
上面的代码非常适合我。此外,您还必须按照以下链接逐步进行深度链接 Android Studio
https://developer.android.com/studio/write/app-link-indexing.html
https://developer.android.com/training/app-links/deep-linking
推荐阅读
- python - Python 脚本,正方体。没有错误但没有输出
- python - Python TkInter 创建一个按钮来打开特定目录
- firebase - Flutter Firestore 实时计数文档
- angular - 对于单元测试中没有构造函数的扩展类,Angular 10 依赖注入失败
- python - 我在 Python 中创建了商店计算器,但它有一些错误
- php - 如何将 HTML 内容和特殊字符转换为 Html 实体
- spring - 我可以从实体设置数据库序列的最小/最大值吗?
- python - Python绘图不是从中心开始
- python - 如何将创建的文本通道添加到类别?
- python - 我对变量做错了什么?