Do you know a way to detect that the back or set wallpaper button is pressed on a livewallpaper preview mode screen?
Asked
Active
Viewed 999 times
1 Answers
0
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.

A Honey Bustard
- 3,433
- 2
- 22
- 38