【问题标题】:An implicit deep link from a notification in JetpackNavigation library来自 JetpackNavigation 库中通知的隐式深层链接
【发布时间】:2020-08-16 03:08:45
【问题描述】:

我正在尝试在我的应用程序中实现隐式深层链接处理,但以下代码不起作用,并且我的单个活动中的 onNewIntent 没有调用,但导航图中的 startDestination 始终处于打开状态。

在我的导航图中,我有以下片段的深层链接

 <deepLink
        android:id="@+id/deepLink"
        app:uri="people/{uuid}" />

然后我添加了导航。活动标签之间的图表到清单文件

<nav-graph android:value="@navigation/app_graph" />

在我将 onNewIntent 实现放到 MainActivity 之后,它看起来像

 override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    findNavController(R.id.fragmentContainer).handleDeepLink(intent)
}

待定意图的创建过程如下:

val intent = Intent(context, MainActivity::class.java).apply {
    flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
    data = Uri.parse("people/$uuid")
}

val pendingIntent = PendingIntent.getActivity(
    context,
    PENDING_INTENT_REQUEST_CODE,
    intent,
    0
)

最后是对话框的创建

val notification = NotificationCompat.Builder(context, CHANNEL_ID)
        // not important
        .setContentIntent(pendingIntent)
        .setPriority(NotificationCompat.PRIORITY_DEFAULT)
        .build()

NotificationManagerCompat
    .from(context)
    .notify(Random.nextInt(), notification)

【问题讨论】:

  • 你找到解决办法了吗?
  • 你解决了吗?

标签: android kotlin android-notifications deep-linking android-jetpack-navigation


【解决方案1】:

我认为首先你的方案是错误的,应该是&lt;scheme_name&gt;://people/{uuid}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2016-01-05
    • 2021-11-13
    • 1970-01-01
    相关资源
    最近更新 更多