小编gro*_*myk的帖子

Kotlin 默认使用什么样的排序?

.sort()、.sortWith()等方法使用哪种排序?

val array = arrayOf(3,2,1)
Run Code Online (Sandbox Code Playgroud)

不同类型和大小的数组的算法是否存在一些差异?

sorting algorithm kotlin

11
推荐指数
1
解决办法
1849
查看次数

来自 JetpackNavigation 库中通知的隐式深层链接

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

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

 <deepLink
        android:id="@+id/deepLink"
        app:uri="people/{uuid}" />
Run Code Online (Sandbox Code Playgroud)

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

<nav-graph android:value="@navigation/app_graph" />
Run Code Online (Sandbox Code Playgroud)

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

 override fun onNewIntent(intent: Intent?) {
    super.onNewIntent(intent)
    findNavController(R.id.fragmentContainer).handleDeepLink(intent)
}
Run Code Online (Sandbox Code Playgroud)

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

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
)
Run Code Online (Sandbox Code Playgroud)

最后创建对话框

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

NotificationManagerCompat
    .from(context)
    .notify(Random.nextInt(), notification)
Run Code Online (Sandbox Code Playgroud)

android deep-linking android-notifications kotlin android-jetpack-navigation

10
推荐指数
1
解决办法
1072
查看次数