What happens when i back from activity to watch face

Hi,

I m working to optimize my watch face.

Then i only redraw elements wich needed to be redraw due to value change.

When i switch from watch face to widgets list and back no problem. i guess view.onupdate is called and then all draw() from drawables are called.

But when i switch to activity and back to watch face i got a display bug. drawables are displayed 2 times with first a lower sized layout. (no full clear called)

I woul know how to detect back from activity list to force full redraw.

Thank for any suggest.

  • This is actually the reason you don't want to do what you're doing.  Things like a "toast" for something like External HR connected cover the top part of the screen, but you can't see that happened in a WF, so you don't know what to re-draw.  Since onUpdate() is usually only called every minute, it's safest to just redraw everything.  You can do things like display additional infor based on onEnterSleep()/onExitSleep() (a "gesture"), but that might not be consistent enough on various devices.

    There's also onPartialUpdate() where you can do things like "seconds all the time", or an active HR display.

    To help optimize stuff, you may want to look at how you calculate things - like you don't need to re-calculate sunrise/sunset each time it's displayed, only when the day changes.

    And there are things in the code in general.  One example I use is how "has" is used.  Things like that can be used to set a boolean in initialize(), so that "has" isn't called every time in onUpdate().  Same with settings/storage.  You really only need to access the settings at two points - when the app starts and in onSettingsChanged(), and then put things in a variable vs calling Application.Properties.getValue() each time onUpdate is called.  Same with storage.  Don't read something except at startup and then save it in a variable vs reading it each call to onUpdate() and the only write it if it's changed.

  • This is also something you'll never see in the sim, and when/where could vary by devices.

  • Thank for reply, will deal with that.