Mong H. Ng
Mong H. Ng

Reputation: 980

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.

Thanks.

Upvotes: 1

Views: 45

Answers (1)

Dan Hartman
Dan Hartman

Reputation: 194

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.

Upvotes: 2

Related Questions