Android Service.startForeground does NOT respect notification id uniqueness

前端 未结 1 1811
夕颜
夕颜 2020-12-31 22:54

Service.startForeground() vs NotificationManager.notify(), give different behaviors.

When using notify with two different notification ids, 2 notifi

相关标签:
1条回答
  • 2020-12-31 23:23

    Well, it's not the best solution, but you can always just "reassign" a notification to a dismissed notification ID. For example, say you start Process 1 (foreground) and then Process 2 (using NotificationManager). When Process 1 ends, dismiss the notification for Process 2 and update the foreground notification for Process 1 to actually now show the progress for Process 2.

    That way you don't have to call stopForeground() and startForeground(), which may allow the service to be killed in between (haven't actually checked that's true, though).

    0 讨论(0)
提交回复
热议问题