Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android JetpackNavigation库中通知的隐式深度链接_Android_Kotlin_Android Notifications_Deep Linking_Android Jetpack Navigation - Fatal编程技术网

Android JetpackNavigation库中通知的隐式深度链接

Android JetpackNavigation库中通知的隐式深度链接,android,kotlin,android-notifications,deep-linking,android-jetpack-navigation,Android,Kotlin,Android Notifications,Deep Linking,Android Jetpack Navigation,我试图在我的应用程序中实现隐式深度链接处理,但是下面的代码不起作用,我的单个活动中的onNewIntent没有调用,但是总是从导航图中打开startDestination 在我的导航图中,我有一个片段的深层链接 <deepLink android:id="@+id/deepLink" app:uri="people/{uuid}" /> 正在创建挂起的意图,如下所示: val intent = Intent(context, MainActivit

我试图在我的应用程序中实现隐式深度链接处理,但是下面的代码不起作用,我的单个活动中的onNewIntent没有调用,但是总是从导航图中打开startDestination

在我的导航图中,我有一个片段的深层链接

 <deepLink
        android:id="@+id/deepLink"
        app:uri="people/{uuid}" />
正在创建挂起的意图,如下所示:

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)

你找到解决办法了吗?你能解决吗?
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)