How to update notification power efficiently every minute to display time in hour and minute in Android?

87 Views Asked by At

I have a calendar app which need to display Current Date and time and Events(Holidays) in the notification bar of a country(i.e India) even when app is closed or in Background. I made customized notification bar and implemented using remote views. I used broadcast receiver and foreground service to implement these functions. But i got too many problems.

  1. Notification disappears randomly in a day or two.
  2. android.app.RemoteServiceException crash
  3. android.app.ForegroundServiceStartNotAllowedException
  4. Context.startForegroundService() did not then call Service.startForeground()

etc. Android introduces new features such as work manager instead of using foreground service however they do not allow updating every minute. But i need to show hour and minute and update it every minute. As of end of 2023 which technologies (Alarm Manager, Broadcast Receiver, BOOT_COMPLETED, ACTION_TICK, DATE_CHANGED, WorkManager, Handler, Timer etc) should i use to make an app ANR and crash free. I have attached image for better understanding. Please Help. enter image description here

0

There are 0 best solutions below