DeepLink仅在JetPack Navigation中使用斜线时起作用

发布于 2025-02-13 08:20:10 字数 1473 浏览 1 评论 0原文

我正在尝试使用 &lt; nav-graph&gt; 发电机以生成&lt; intent-filter&gt;我的androidmanifest.xml < elements.xml < /code>

在我的nav_graph.xml中的片段之一中,我补充说:

<deepLink app:uri="axzae://notifications" />

在生成的apk中, androidManifest.xml现在看起来像是下面的

<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="axzae" />
  <data android:host="notifications" />
  <data android:path="/" />
</intent-filter>

,问题在于附加android:path =“/”。 应用程序仅响应axzae:// notifications/而不是axzae:// notifications(请注意结束斜线)

它使该 >&lt; nav-graph&gt; 支持axzae:// notifications deeplink或不生成&lt;数据android:path =“/”/&gt; line?

I'm trying to use <nav-graph> generator to generate <intent-filter> elements in my AndroidManifest.xml

In one of the fragments in my nav_graph.xml, I added:

<deepLink app:uri="axzae://notifications" />

In the generated APK, the AndroidManifest.xml looks like below

<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="axzae" />
  <data android:host="notifications" />
  <data android:path="/" />
</intent-filter>

Now, the problem is with the additional android:path="/". It made the app only respond to axzae://notifications/ but not axzae://notifications (take note of the ending slash)

Is there anywhere I can make <nav-graph> to support axzae://notifications deeplink or without generating the <data android:path="/" /> line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿光 2025-02-20 08:20:10

显然,JetPack导航无法解析生成的axzae:// notifications/。该应用程序已启动,但它将始终打开您的StartDestination。所以它实际上是破碎的。

要注意的另一件事是,对于第二层深链接,它可以正常工作。示例axzae:// Notifications/settings将正常工作。

我将通过手动在androidmanifest.xml中手动填充TLD/HOST-host-host-host-host-form-host-host-host-host-host-host-the Deep链接来求助于解决方法。

<activity
  android:name=".ui.MainActivity"
  android:exported="true"
  android:theme="@style/Theme.App">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  
  <nav-graph android:value="@navigation/nav_graph" />

  <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="axzae" />
    <data android:host="home" />
    <data android:host="notifications" />
    ...
  </intent-filter>
</activity>

apparently, jetpack navigations can't resolve the generated axzae://notifications/. the app launched but it will always open up your startDestination. so it's actually broken.

another thing to note is it works fine for second-layer deep links. Example axzae://notifications/settings will work fine.

I will resort to a workaround for now by manually populating the TLD/host-only deep links in AndroidManifest.xml

<activity
  android:name=".ui.MainActivity"
  android:exported="true"
  android:theme="@style/Theme.App">
  <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
  </intent-filter>
  
  <nav-graph android:value="@navigation/nav_graph" />

  <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="axzae" />
    <data android:host="home" />
    <data android:host="notifications" />
    ...
  </intent-filter>
</activity>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文