getContext() seems to be null when using the sketch as a Wallpaper. Maybe the context could be the Service used for the wallpaper itself.