3

When you want to handle a click in your life wallpaper you should use onCommand and wait for the action WallpaperManager.COMMAND_TAP. This is described e.g. in the discussion thread: Android Live Wallpaper Touch Event Hierarchy.

This works fine on my phone, but when i deploy the wallpaper to a tablet (in my case the motorola xoom with android 3.1) COMMAND_TAP is also triggered, when an icon on the home-screen is pressed.

I added a workaround by storing the visible state and delaying the onCommand handling by 1000ms, but I would like a real solution for this problem.

Community
  • 1
  • 1
Gizmomogwai
  • 2,496
  • 1
  • 20
  • 21
  • I'm seeing this on the Samsung Galaxy S II also, but not on most other phones. It also happens when a widget is pressed. Can you give details of your workaround? – Kenton Price Jan 19 '12 at 11:41
  • How is this still a problem on Android 8.0?! Nexus 5x stock factory image. – Flyview Oct 29 '17 at 22:08
  • I reported it on the Android issue tracker: https://issuetracker.google.com/issues/68467342 – Flyview Oct 30 '17 at 00:46

1 Answers1

0

We're having the same issues with Samsung phones, only verified on the Droid Charge SCH-I510 and S2. The S3 does not exhibit the behavior.

Here is the workaround, that Gizmomogwai mentioned in code.

public Bundle onCommand(String action, int x, int y, int z, Bundle extras, boolean resultRequested) {
  if (WallpaperManager.COMMAND_TAP.equals(action)) {
    final CustomWallpaperEngine that = this;
    Handler handler = new Handler();

    handler.postDelayed(new Runnable() {
      public void run() {
        if(that.isVisible()) {
          // valid tap command
          // DO STUFF
        } else {
          // Invalid tap command, throw away
        }
      }
    }, 1000);
  }
}
waynep
  • 51
  • 2