0

Background

I've made a live wallpaper that can handle touch events .

The problem

There are some cases which I don't want it to handle touches (or listen to other events). This help prevent weird drawing and also save on the battery a bit.

For example, on Lollipop, I've noticed that when you show the recent tasks screen, the live wallpaper still has focus. This didn't happen on pre-Lollipop, because the recent tasks screen took over everything on the screen.

Another example is the wallpaper-chooser, even if you just show thumbnails of all live wallpapers, you would still show your own and handle touch events, as if the user is on the launcher.

However, when you show the notification bar or the menu of the launcher (by pressing the menu button), the live wallpaper will not get any touch events.

You can see those issues on other live wallpapers, like "Magic fluids free" for example.

Again, the problem is that on some cases, there is no way to disable the touch events, because you can't know when they happen (recent tasks and wallpaper chooser are such examples).

What I've tried

There isn't much to do. all of the methods of the Engine class failed to find the state of the sceneraios I've written about:

onOffsetsChanged, onVisibilityChanged, onSurfaceChanged, onSurfaceRedrawNeeded, onOffsetsChanged

The question

Is there any way to overcome this issue? To stop listening to events in case the live wallpaper isn't on focus?

android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

0

How about setting

    setTouchEventsEnabled(false);

in your WallpaperService Engine class, when you don't want touchs to be handled, and set it to true when you do.

A Honey Bustard
  • 3,433
  • 2
  • 22
  • 38
  • Sure, but the problem is not that. The problem is that I don't get the event of Lollipop showing the recent tasks, so I can't know when to disable and when to enable... :( I've edited the question to clarify it a bit further. – android developer Jan 19 '15 at 09:17
  • BTW, I could just ignore touch events if I want to, instead of using "setTouchEventsEnabled(false)" . Again, the problem is that I don't know how to get when to do it. There are no triggers that I've found for those scenarios. – android developer Jan 19 '15 at 09:24