Android:服务类中startForeground(id,notification)的id是多少

Ovi*_*Ovi 7 service notifications android

startForgroundService 类中方法中的 id 参数是什么。我通过谷歌搜索单个 Notification 找到了答案。这家伙如何找到 id ?对此的任何列表或参考。如果我想显示多个通知(如 facebook)怎么办。那么我如何定义 id 呢?

notification.flags = Notification.FLAG_NO_CLEAR;
startForeground(1337, notification);
Run Code Online (Sandbox Code Playgroud)

God*_*ave 2

简单的 notification_id 需要改变。

只需为 notification_id 创建随机数即可。

    Random random = new Random();
    int m = random.nextInt(9999 - 1000) + 1000;
or
        int m = System.currentTimeMillis()%10000;
Run Code Online (Sandbox Code Playgroud)

并替换此行以添加通知 id 的参数以生成随机数

    startForeground(m, notification);
Run Code Online (Sandbox Code Playgroud)