1

I have an activity I used a timer here and and want it to reset on user interaction changed, it is working fine, but after I reenter the Activity, onUserinteraction method is not called when user touches the screen.

   @Override
    public void onUserInteraction() {
            super.onUserInteraction();
            // reset the timer with user interaction
            if (flag == 0) {
                timer.cancel();
                timer.start();
          }
    }
Fun Mun Pieng
  • 6,751
  • 3
  • 28
  • 30
Jewel
  • 13
  • 1
  • 6

1 Answers1

2

Read the documentation

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. This callback and onUserLeaveHint() are intended to help activities manage status bar notifications intelligently; specifically, for helping activities determine the proper time to cancel a notfication.

All calls to your activity's onUserLeaveHint() callback will be accompanied by calls to onUserInteraction(). This ensures that your activity will be told of relevant user activity such as pulling down the notification pane and touching an item there.

Note that this callback will be invoked for the touch down action that begins a touch gesture, but may not be invoked for the touch-moved and touch-up actions that follow.

It's called only when the user interacts with the device

Saeed Masoumi
  • 8,746
  • 7
  • 57
  • 76