When creating a watch face for Android Wear devices, you may want to include a phone app for configuration. A preview of the watch face in the configuration app provides immediate feedback of the changes and makes it more comfortable for users to change settings.
To achieve this, you have to put the drawing code in a separate class, which can be reused in the phone app and the watch face service. First, create a separate Android Library module, where you put the common classes and resources for drawing the watch face. In this module, create an interface IWatchFaceConfig, which exposes your configuration options.
public interface IWatchFaceConfig { Calendar getCalendar(); boolean isAmbient(); boolean isLowBitAmbient(); boolean isRound(); // put your watch face options here boolean isLightTheme(); }
In your phone app and watch face service, you can now either choose to directly implement IWatchFaceConfig, or you can make a WatchFaceConfig class, if you prefer to have a separate configuration object. When you directly implement the interface, you have to be careful to avoid memory leaks (for example if your Activity implements the interface).