Gra*_*Fox 5 android deep-linking firebase firebase-dynamic-links
我在iOS应用上实现了Firebase Dynamic链接(太棒了!),现在在Android上执行相同的工作。我设法通过单击动态URL来启动我的Android应用程序,但是我无法在启动器活动之外的其他活动上打开它。
这是我的manifest.xml文件:
<activity android:name=".Activity.SplashActivity"
android:theme="@style/SplashTheme"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity.RouteListActivity"
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:host="mywebsite.com" android:scheme="http"/>
<data android:host="mywebsite.com" android:scheme="https"/>
<data
android:host="myapp.app.goo.gl/"
android:scheme="https" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
当我单击URL时,浏览器打开并重定向到我的应用程序,但按预期在SplashActivity而不是RouteListActivity上打开。
我想念什么吗?
谢谢
好吧,我想我找到了一个能够克服这个问题的简单解决方法。
我想起我开发的一个应用程序,其中动态链接在以前的版本中运行良好,我刚刚再次测试它们以确认(这里有一个示例动态链接来证明它确实有效);所以我去查看它的清单来了解我当时做了什么。
android:autoVerify=true基本上,向意图过滤器添加一个很重要的内容,如下所示:
<intent-filter android:autoVerify="true">
Run Code Online (Sandbox Code Playgroud)
它将请求验证应用程序链接,您可以在此处阅读以更好地理解它。
由于此解决方案仅适用于 API 23,因此我建议tools:targetApi="23"也添加“这告诉工具您认为此元素(以及任何子元素)将仅在指定的 API 级别或更高级别上使用”,并避免不必要的 Lint 突出显示然后。
因此,处理此问题的最佳方法是添加以下代码:
<intent-filter
android:autoVerify="true"
tools:targetApi="23">
Run Code Online (Sandbox Code Playgroud)
值得一提的是,用户端的“设置为默认”选项可能会忽略此选项,具体取决于用户使用链接的方式,因为它可能会出现一个弹出窗口,提供有关如何处理链接的选择,并且可能会产生某种误导(这两个至少考虑到我的应用程序和设备,选项看起来是一样的)。
在这个问题中出现的示例清单文件中,它看起来像这样:
<activity android:name=".Activity.SplashActivity"
android:theme="@style/SplashTheme"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity.RouteListActivity"
android:screenOrientation="portrait">
<intent-filter
android:autoVerify="true"
tools:targetApi="23">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="mywebsite.com" android:scheme="http"/>
<data android:host="mywebsite.com" android:scheme="https"/>
<data
android:host="myapp.app.goo.gl/"
android:scheme="https" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
xmlns:tools="http://schemas.android.com/tools"并且不要忘记在清单的开头添加。
| 归档时间: |
|
| 查看次数: |
2370 次 |
| 最近记录: |