应用程序在后台和终止时点击通知有什么区别

What's the difference between tapping notification when app is on background and terminated

通过类型3(打开应用)点击带有消息数据的通知时,消息数据都是从onNewIntent方法获取的,应用在后台和终止时有什么区别吗?

如果应用在后台点击通知,会回到初始界面还是保持之前的路由路径?

当您点击通知时,它将转到您在创建通知时指定的 Intent。那里没有区别。如果应用程序被终止,则需要重新启动。在那种情况下,内存中存在的任何数据都将丢失,因此处理通知所需的任何内容都需要写入磁盘。

当 Activity 的启动模式设置为 single task 时,当用户点击已设置 setContentIntent(pendingIntent) 的通知时,将调用 onNewIntent 回调. 如果应用程序已经 运行 并且对用户可见,则不会调用 onCreate,但会调用 onNewIntent。如果应用尚未 运行 并且对用户不可见,则将调用 onCreate。在 onNewIntent 中,传递到 pendingIntent 的意图将被传送到 onNewIntent