0

Just starting working with Wear. Having trouble figuring out how get a user chosen bitmap prepared and ready before the onDraw. I can hard code it in onCreate but can't figure out how to deal with config options (I'm familiar with shared preferences in normal programming) I've read some smatterings of info on data and messages but I've literally put a Log.d in every class and can't seem to get anything to happen before the first onDraw of the watch service.

UPDATE: I very carefully looked at the WatchFace demo and when you change the background color, switch watchfaces, switch back, as the the newly changed background color watchface comes up, it starts using the default (black) color and then flicks to the new color. I want to avoid this behavior.

John Smith
  • 3,493
  • 3
  • 25
  • 52
  • I'm not sure I fully understand what the problem is. If you are trying to get a background image prepared before the onDraw, you should use onSurfaceChanged like in the sample here: https://github.com/googlesamples/android-WatchFace/blob/master/Wearable/src/main/java/com/example/android/wearable/watchface/SweepWatchFaceService.java#L174 does this do what you want? – Wayne Piekarski Jul 22 '15 at 18:33
  • The background color in ambient mode is always black, so perhaps that is what you might be referring to with the colors? The watch always changes between ambient and interactive mode as part of its operation. – Wayne Piekarski Jul 22 '15 at 18:34
  • Thanks for your comment. I'm using that sample. What I'm trying to do is initialize the bitmap using a previously chosen from the config. So basically, I just need to capture config info BEFORE onSurfaceChange. – John Smith Jul 22 '15 at 21:43
  • I'm still confused as to what you are asking here. Configuration events are handled by onDataChanged, and then take effect on the next onDraw. Ambient mode forces the background to be black, this is not a configuration option. Please give more detail about what is happening and in what order, and perhaps we can help. – Wayne Piekarski Jul 23 '15 at 01:35
  • Wayne: I feel like I'm missing something easy, but looking at the documentation for implementing a Configuration activity, there doesn't seem to be an explanation on how to retrieve already changed configuration info. Let's say a user changes the watch face color to green from the default, which is black, using a Configuration utility from a phone companion app. The user reboots his wear device. How does the watch face app get the configuration information from inside onCreate() to display the new "default" green background instead of black? – John Smith Jul 23 '15 at 15:59
  • 1
    The configuration activity on the phone retrieves the current configuration using the call to getDataItem here https://github.com/googlesamples/android-WatchFace/blob/master/Application/src/main/java/com/example/android/wearable/watchface/DigitalWatchFaceCompanionConfigActivity.java#L103 ... this is where we query the data layer to find the values, then we populate the UI with them. So the Activity always has the latest values. (let me find references to the other parts) – Wayne Piekarski Jul 23 '15 at 19:41
  • Messages are sent from the phone to the wearable when changes are made. And finally, putDataItem is used on the wearable side to update the data layer. – Wayne Piekarski Jul 23 '15 at 20:00

0 Answers0