Search code examples
androidandroid-custom-view

How to check if a view wasn't touched for a specific time


I have a custom view and i want it to do something when the user stops touching it for more then 500 milliseconds.

How can i check this?

I was thinking of having a thread polling the current millisecond time and checking it with the last touch.

is there a better approach with out polling?

Thanks


Solution

  • Every time the user stop touching the view you can open a postdelayed thread for 500ms , in the runnable of the last perform a check if the view has been touched during this period (using a Boolean flag) , if not make the needed operation.