0

I want to show seconds in a watchface. In normal mode as well as in ambient mode. General Handler thread Handler handler = new Handler( /* Runnable{ invalidate(); handler.postDelayed(this, 1000);}*/ ) Works fine to update time and show it in screen while in normal mode but it sleeps and slips so far away and executes in random time while in ambient mode. Well this is nothing new and android doc and everyone says to update screen in every minute instead of a second. But I want the watchface to show seconds and that should be updated in every seconds despite battery life. And I can not find a answer for this.

I definitely tried ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();. All gave similar result and among these ScheduledExecutorServices schedule at fixed rate method gave worst performance. In my opinion AlarmManager is overkill for this purpose. The thread is created in onCreate method and is not changed.


Now someone please tell me a way to update the screen in every second while in or out of ambient mode.


Note: All thread works fine on wear OS emulator but on actual watch it shows this behaviour, that is executed in a random time, like in every 20 seconds.

Rifat
  • 1,700
  • 3
  • 20
  • 51
  • The reason this isn't working for you is because you really shouldn't be doing it. :) Ambient mode is supposed to update once a minute to save battery. The official development guidelines states that the second hand should be removed when the device enters ambient mode (https://developer.android.com/codelabs/watchface#3). I highly recommend following the guidelines. – TofferJ Dec 07 '20 at 17:46
  • Thanks for your opinion. I know about this and I mentioned it on the post. I do not care about battery because there can be any exception to the ambient mode usage. My app requires to show seconds. Eg: StopWatch. So it is not a good idea to show seconds every minute. – Rifat Dec 08 '20 at 09:28
  • @Rifat I am struggling with the same issue, did you found a solution? – Jonathan Applebaum Dec 15 '21 at 20:31

0 Answers0