0

I write a program to capture screen touch event. But when the screen is off, I can't get any MotionEvent ev.

private PowerManager pm = null;
private PowerManager.WakeLock wl = null;
this.pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
this.wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "test");
wl.acquire();

@Override
public boolean dispatchTouchEvent (MotionEvent ev) {
    if(ev.getAction() == MotionEvent.ACTION_DOWN)
        Log.i("test", "!!!");
    return true;
}
JACK M
  • 2,627
  • 3
  • 25
  • 43
  • This should answer the question for you: https://stackoverflow.com/questions/21572750/touch-event-while-display-off – rmutalik Sep 25 '19 at 23:11

1 Answers1

-1

you can use Intent.ACTION_SCREEN_ON and Intent.ACTION_SCREEN_OFF to achieve your goal. this link might help you.

Om3ga
  • 30,465
  • 43
  • 141
  • 221