简体   繁体   English

即使应用未运行,如何连续更新通知?

[英]How to continuously update notification even when app is not running?

I am trying to implement a timer with notification that cannot be swiped away by user. 我正在尝试实现一个带有通知的计时器,该通知不能被用户抹去。 I want to continuously update the timer's time. 我想不断更新计时器的时间。

I know there are a lot of similar question online. 我知道在线上有很多类似的问题。 But a lot of them discuss using handler, or a service. 但是许多人讨论使用处理程序或服务。 All of these won't run when my app is not being used by the user. 当用户不使用我的应用程序时,所有这些都将无法运行。 AlarmManager doesn't work because i want to update every x millisecond. AlarmManager不起作用,因为我想每隔x毫秒更新一次。

Thanks. 谢谢。

Use a foreground service 使用前台服务

A foreground service performs some operation that is noticeable to the user. 前台服务执行一些用户注意的操作。 For example, an audio app would use a foreground service to play an audio track. 例如,音频应用程序将使用前台服务来播放音轨。 Foreground services must display a Notification. 前台服务必须显示通知。 Foreground services continue running even when the user isn't interacting with the app. 即使用户未与应用程序进行交互,前景服务也将继续运行。

There is a limit on how frequently you can update the notifications as well, every MS will cause problems. 您还可以多长时间更新一次通知,每个MS都会引起问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何显示通知甚至应用程序未运行 - How to show a notification even app is not running 如何在没有用户交互的情况下自动更新连续运行的Android应用 - How to auto update a continuously running Android app without user interaction 即使应用程序未运行,如何通过通知点击触发应用程序中的弹出窗口 - How to trigger pop-up in app via notification click even when app is not running 如何安排3个事件通过android中的(通知栏)通知用户,即使我的应用未运行,该事件也会运行 - How to schedule 3 events to notify user via (notification bar) in android which runs even when my app is not running 即使应用未在Android中运行,如何按时间或间隔发送通知? - How to send notification by timing or interval even the app is not running in Android? 应用程序未运行时如何发送 fcm 通知 - How to send fcm notification when app is not running 应用程序运行时如何停止通知? - How to stop notification when app is running? 如何在应用未运行时显示通知 - how to show notification when app is not running 即使应用程序没有运行,当收到来自特定应用程序的通知时运行我的特定代码块 - Run my particular block of code when receive notification from particular app even when app is not running 即使应用程序被杀死,如何向Android设备发送推送通知? - How to send push notification to android devices even when app is killed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM