onShow for watch faces

Hi, I have developed some simple watch faces before and followed sample code I found here and elsewhere. I did not care to much about the watch face "life cycle", I just re-used the approach used in the samples, and everything worked as I wanted. 

Now I have started to dig down a bit more into the different functions in the watch face view class and how I should use them. Previously I would do most of the work in the onUpdate() function. I loaded the resources in onLayout and I populated the class variables from settings in initialize(), but never used the onShow() function. 

I am trying to figure out when onShow() is called in my case. My watch face does not provide in-app settings and only have one main view without subviews or submenus. 

If I were to change my code I was leaning towards this:

1. load settings and populate class variables in initialize()

2. load resources in onLayout()

3. update view in onUdpate() 

But what should I do in onShow()? Do I need it at all?

Thanks!

/Fredrik

  • This is from sample app:

    // Called when this View is brought to the foreground. Restore

    // the state of this View and prepare it to be shown. This includes

    // loading resources into memory.

        function onShow() {

        }

    You can put System.println there and see when it gets called. I don't have anything there, but I load and release resources using different mechanism.

    Take a look at sample apps in SDK and on Peter's starttorun site - they'll give you some guidance.