How to check if user touched anything?

135 Views Asked by At

I want to know when the user is interacting with my app. I've tried to use Window.Callback but I faced an issue with Toolbar.

In case we call setSupportActionBar (setActionBar) my Window.Callback doesn't receive events anymore.

Restriction:

I can't extend Activity. I need one global place to handle all interactions with the app.

2

There are 2 best solutions below

0
On

Try onUserInteraction().

Called whenever a key, touch, or trackball event is dispatched to the activity. Implement this method if you wish to know that the user has interacted with the device in some way while your activity is running.

0
On

You can achieve that with overriding onUserInteraction method on your activity

@Override
public void onUserInteraction(){
  //do what you like here
}

See docs for furhter informations docs