Do you know a way to detect that the back or set wallpaper button is pressed on a livewallpaper preview mode screen?
OnDestroy() is called when you backpress in that screen. If you choose to set the wallpaper, OnDestroy() is also called. Unfortunately Theres no Overriding onBackPressed(), onPause() or onStop() in a WallpaperService preview.
Heres the order of Lifecycle methods that are called when you start the preview for the first time :
OnCreate() ->
OnSharedPreferencesChanged() (if you have any) ->
OnCreate(SurfaceHolder) (Engine subclass) ->
OnSurfaceCreated() (Engine subclass) ->
OnSurfaceChanged() (Engine subclass) ->
OnVisibilityChanged(true) (Engine subclass) ->
OnVisibilityChanged(false) (Engine subclass) ->
OnVisibilityChanged(true) (Engine subclass) ->
OnOffsetsChanged (Engine subclass)
With the method isPreview() of your Engine Subclass you can at least check if your wallpaper is running in Preview Mode or not.