On Android, is it possible in general to implement LiveWallaper, which reacts to screen touches? In theory, the public void method onTouchEvent (MotionEvent event) to override it has. Wrote a simple piece. No touch reaction. The method is simply not executed. I will give my class successor LiveWallpaper'a:

package com.topsher.indicator; import android.graphics.Rect; import android.service.wallpaper.WallpaperService; import android.util.Log; import android.view.MotionEvent; import android.view.SurfaceHolder; public class IndicatorBlocksWallpaper extends WallpaperService { private Rect surf; private Painter mPainter; private String TAG = "IndicatorBlockWallpaper"; @Override public Engine onCreateEngine() { // TODO Auto-generated method stub return new MyEngine(); } class MyEngine extends Engine { @Override public void onSurfaceCreated(SurfaceHolder holder) { // TODO Auto-generated method stub holder.getSurfaceFrame(); super.onSurfaceCreated(holder); mPainter = new Painter(holder, getApplicationContext()); mPainter.start(); //mPainter.drawIndicator(); // mPainter.runMotion(); //mPainter.start(); } @Override public void onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub super.onTouchEvent(event); //.. Log.d(TAG, "new Touch Event!"); //.. } } 

}

In the event log simply does not register. Installed in the emulator wallpaper just hangs in the background, but does not respond to events. Tell me possible omissions or not at all such an opportunity how to respond to different events "Live Wallpaper"?

  • I think that the opportunity itself is definitely there, since, at least, on my nexus there are two “live wallpapers” that react to finger pressing. - KoVadim

2 answers 2

The whole problem is similar in the setTouchEventsEnabled property, which is false by default :-).

  • Yes thank you. Took an example, but missed this moment .. - zugzug

That of course is possible. I did not understand myself, but I googled this: StackOverflow

I will add a couple of moments:

  1. To implement the wallpaper, you can use the plugin for the AndEngine game engine. It turns out much less code.
  2. See an example of wallpaper in the dock: Tyts