Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I was wondering how to use touch events with a live wallpaper. I recently added a touchevent to MyGLSurfaceView():

@Override
   public boolean onTouchEvent(final MotionEvent evt) {
       float currentX = evt.getX();
       float currentY = evt.getY();
       float deltaX, deltaY;
       switch (evt.getAction()) {
           case MotionEvent.ACTION_MOVE:
               // Modify rotational angles according to movement
               deltaX = currentX - previousX;
               deltaY = currentY - previousY;
               renderer.angleX += deltaY * TOUCH_SCALE_FACTOR;
               renderer.angleY += deltaX * TOUCH_SCALE_FACTOR;
       }
       // Save current x, y
       previousX = currentX;
       previousY = currentY;
       return true;  // Event handled
   }


And it works completely fine for the app that the live wallpaper is created in, the cube moves with my finger and everything. But when I set my live wallpaper as my background on my phone and try to move the cube with my finger, the Cube doesn't move or do anything at all.

What I have tried: I figured since I set the touch event in MyGLSurfaceView() that I should use that surface view in my live wallpaper instead of just calling GLSurfaceView. When I did that the app still worked perfectly fine but the cube still wasn't moving when I touched it. If anyone could help me or has experienced this problem before please leave an answer. Also if you guys need the code for the service part of the live wallpaper app let me know. I have also tried setting touchevents enabled to true in my livewallpaper service class and it still doesn't work.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900