来自服务的持久android通知

来自服务的持久android通知,android,service,notifications,persistent,Android,Service,Notifications,Persistent,如何生成一个持久通知,它将在用户每次看到它时更新? 形成服务要在服务运行时显示通知,请调用: startForeground(R.string.notification_id, myNotification); 为该方法提供服务的ID,以及您创建的通知 在任何时候,您的服务都可以通过使用相同的R.string.notification\u id并发布新的通知来更新用户看到的内容: NotificationManager notificationManager =

如何生成一个持久通知,它将在用户每次看到它时更新?
形成服务

要在
服务
运行时显示通知,请调用:

    startForeground(R.string.notification_id, myNotification);
为该方法提供服务的ID,以及您创建的
通知


在任何时候,您的
服务都可以通过使用相同的
R.string.notification\u id
并发布新的
通知来更新用户看到的内容:

    NotificationManager notificationManager = 
        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(R.string.notification_id, myNotification);

要创建
通知
,您需要阅读
Notification.Builder
()


对于一个相关的问题,也有一个很好的答案:为没有重新发布他的答案而道歉,但其中包含了大量的代码,可以帮助您解决问题。

要在
服务运行时显示通知,请拨打:

    startForeground(R.string.notification_id, myNotification);
为该方法提供服务的ID,以及您创建的
通知


在任何时候,您的
服务都可以通过使用相同的
R.string.notification\u id
并发布新的
通知来更新用户看到的内容:

    NotificationManager notificationManager = 
        (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(R.string.notification_id, myNotification);

要创建
通知
,您需要阅读
Notification.Builder
()


对于一个相关的问题也有一个很好的答案:为没有重新发布他的答案表示歉意,但其中包含了大量代码,可以帮您解决问题。

比如,时间……当用户打开通知幻灯片时,他看到的是当前时间。有可能吗?比如说,时间……当用户打开通知幻灯片时,他看到的是当前时间。可能吗?