2

Do you know a way to detect that the back or set wallpaper button is pressed on a livewallpaper preview mode screen?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Jacques Giraudel
  • 352
  • 4
  • 19

1 Answers1

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