Tuesday, 17 April 2012

Detect tap events on Live Wallpapers

If you want to add some interaction to your live wallpaper, you need to detect when users touch the screen.
You can activate a listener event on your live wallpaper with the method  WallpaperService.Engine#setTouchEventsEnabled.
The method WallpaperService.Engine#onTouchEvent will be automatically called, each time a user touch the screen.
But you have to be careful, this method is also called even when the app drawer is displayed above your wallpaper.
To prevent this behaviour you should instead override the WallpaperService.Engine#onCommand method and check if it was triggered by the tap action.

       public Bundle onCommand(String action, int x, int y, int z, 
                                   Bundle extras, boolean resultRequested) {

              if (action.equals("android.wallpaper.tap")) {
                     // do your things
              return super.onCommand(action, x, y, z, extras, resultRequested);


  1. Along with its Android 5.0 Lollipop release, Google is delivering a brand new and completely redesigned Gmail app for Android. gmail apk

  2. An all around coordinated photo of the desktop would without a doubt encourage you furthermore bring some happiness during a time of the week, since it's extremely helpful to discover, even unwittingly, a continuous and critical for yourself. cheap vinyl banners

  3. Thank you for your information. I love to read it much. Gamingguide