4

I've a free app on the Play Store: Circus Watch Faces and I'm trying to add a watch faces chooser in the configuration activity; I followed the Android Dev Docs about it and no problems, BUT how I can switch from one watch face to another?

I'm completely new to android development so I'm trying to understad from samples and building something new. Currently I've a configuration activity with just a button and when I click on it, I'd like to change the current watch face!

My code is on GitHub (not updated with the config activity yet) if maybe can help a bit.

rene
  • 41,474
  • 78
  • 114
  • 152
Leonardo Gandini
  • 238
  • 1
  • 15

2 Answers2

6

There is no way to change watch face programatically. The best you can do is send a broadcast WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER or (in the new release of Android Wear) WallpaperManager. ACTION_CHANGE_LIVE_WALLPAPER. They will invoke a watch face picker (watch faces are specialized wallpapers). The latter intent also allows you to set your watch face as a proposal for selection in the picker.

The reason for non existence of a way for setting a watch face is that it could be easily abused by apps against user's wishes.

However, since you are trying to do something from your configuration activity, maybe you want to achieve something completely different. Maybe you want to just have one WatchFaceService and then change it (draw it differently) according to some internal settings. This way if the users wants to change the appearance (even to a point where the watch face looks completely different, feels like a new watch face) you just change the underlying data and let the watch face redraw itself.

gruszczy
  • 40,948
  • 31
  • 128
  • 181
1

The closest you can do is the following:

public static void pickYourWatchFace(Context context) {
    ComponentName yourWatchFace = new ComponentName(context, YourWatchFace.class);
    Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
            .putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, yourWatchFace)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}

this will open the Watch Face Picker with YourWatchFace in front of the user, requiring only one tap to set it up.

Louis CAD
  • 10,965
  • 2
  • 39
  • 58