How do I code my app to count till a certain time after say 5 minutes of "INACTIVITY"?

I can run a timer, but I am not sure how to allow my app to recognize INACTIVITY.

Any help is greatly appreciated,
Daniel Christie