From 2acb9323028b3eee11c0509c3ac4cd5ac238312f Mon Sep 17 00:00:00 2001
From: Bert McMeen In addition to accommodating notification cards and system indicators, you need to ensure that
-the animations in your watch face run smoothly and that your service does not perform unnecessary
-computations. Watch faces in Android Wear run continuously on the device, so it is critical
-that your watch face uses power efficiently. This lesson has tips for conserving power and improving performance.
+A watch face runs continuously, so it must use power
+efficiently. This lesson provides some tips to speed up your animations and to measure and conserve
-power on the device. Services must not perform unnecessary computations.
+Watch faces with animations must run smoothly while accommodating
+notification cards and system indicators. This section contains best practices for improving efficiency during
+periods when a watch face is inactive. Ensure that your watch face performs
+computations only when active; use callbacks
+in {@code WatchFaceService.Engine}.
+Preferably, use the following methods of that class to determine if
+the watch face is visible: Alternatively, use the following methods of the same class
+({@code WatchFaceService.Engine}): To listen for events, use live listeners that are registered
+with {@code DataApi.addListener}.
+For an example, see Syncing Data Items. Do not use {@code WearableListenerService} to listen for
+events, because it is
+called whether or not a watch face is active. For more information, see
+Deprecation of BIND_LISTENER
+with Android Wear APIs. Do not register a broadcast receiver in the Android manifest file
+to get system events such as time zone changes, battery events, etc., because
+the {@code BroadcastReceiver}
+is called whether or not a watch face is active. However, you can use the
+{@code registerReceiver} method
+of the {@code Context} class to register a receiver. The
+Android Wear companion app enables developers and users to see how much battery
+is consumed by different processes
+on the wearable device (under Settings > Watch
+battery). For information about features introduced in Android 5.0 that help you improve battery life,
+see Project Volta. The best practices in this section help to reduce the power consumption of animations. Animations are often computationally expensive and consume a significant amount of power. Most
+animations look fluid at 30 frames per second, so you should avoid running your animations
+at a higher frame rate. Animations and small changes to the contents of the watch face wake up the CPU. Your watch
+face should let the CPU sleep in between animations. For example, you can use short bursts of
+animation every second in interactive mode and then let the CPU sleep until the next second.
+Letting the CPU sleep often, even briefly, can significantly reduce power consumption. To maximize battery life, use animations sparingly. Even a blinking colon wakes up the CPU with
+every blink and hurts battery life.This lesson teaches you to
+
You should also read
Basic Optimization
+Use callbacks in WatchFaceService.Engine
+
+
+
+
+
+
+
+Use listeners registered with the DataApi interface
+
+Monitor power consumption
+
+Best Practices for Animations
+
+Reduce the frame rate of animations
+
+Let the CPU sleep between animations
+
+Reduce the Size of Your Bitmap Assets
@@ -68,16 +155,12 @@ by 97%.
Reducing the size of your bitmap assets as described in this section not only improves the performance of your animations, but it also saves power.
- -If you have bitmaps that are often drawn together, consider combining them into the same graphic asset. You can often combine the background image in interactive mode with the tick marks to avoid drawing two full-screen bitmaps every time the system redraws the watch face.
- -When you draw a scaled bitmap on the {@link android.graphics.Canvas} object using the {@link @@ -139,35 +222,3 @@ implementation is short and consistent across invocations. For more information, see Using DDMS.
- - -In addition to the techniques described in the previous sections, follow the best -practices in this section to reduce the power consumption of your watch face.
- -Animations are often computationally expensive and consume a significant amount of power. Most -animations look fluid at 30 frames per second, so you should avoid running your animations -at a higher frame rate.
- -Animations and small changes to the contents of the watch face wake up the CPU. Your watch -face should let the CPU sleep in between animations. For example, you can use short bursts of -animation every second in interactive mode and then let the CPU sleep until the next second. -Letting the CPU sleep often, even briefly, can significantly reduce power consumption.
- -To maximize battery life, use animations sparingly. Even a blinking colon wakes up the CPU with -every blink and hurts battery life.
- -The -Android Wear companion app lets developers and users see how much battery different processes -on the wearable device are consuming under Settings > Watch -battery.
- -For more information about new features in Android 5.0 that help you improve battery life, -see Project Volta.