I want to detect "user inactivity" in my Android app. More precisely: I want to determine if the user has made any interaction with my application (touching the screen, scrolling, entering text ...) for a certain time. Technically, I use a timer that resets on every (user) interaction.
In my activity, I override the onUserInteraction method to detect interactions such as scrolling, touching the screen ...
@Override
public void onUserInteraction(){
resetInactiveTimer();
}
Unfortunately, onUserInteraction is not called when the user interacts with the soft keyboard. I think the reason is that the soft keyboard is not part of my activity.
For edit texts in my application, I use TextWatcher and the onTextChanged method, which works fine. But my application also contains a WebView that loads arbitrary web pages. Of course, some web pages may contain input fields, and I don’t know how to detect that the user interacts with the soft keyboard to edit these text fields.
source
share