Android JetpackNavigation库中通知的隐式深度链接
我试图在我的应用程序中实现隐式深度链接处理,但是下面的代码不起作用,我的单个活动中的onNewIntent没有调用,但是总是从导航图中打开startDestination 在我的导航图中,我有一个片段的深层链接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
<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)