determinig total time for which my application is not interacted with by the user in android

70 Views Asked by At

I am working in android and i am creating an app for Google TV. I am new and have no local help so i am really asking too many questions.

I want to keep track of the time in which my application is free and user does not interacts with it.

For example if user has not interacted with our application for 2 minutes, we would show him some ad etc. which will be hidden when he starts interaction or upon some "Close" button.

Its kind of screen savor.

Your help is greatly appreciated.

2

There are 2 best solutions below

2
On BEST ANSWER

Use the onTouch listener in your layouts for the views that require user interactions.
At the starting of the app, start the timer, if user touches some thing cancel it and restart it again.
This way you can count the time for which user has not responded to the app.

0
On

For example if user has not interacted with our application for 2 minutes, we would show him some ad etc. which will be hidden when he starts interaction or upon some "Close" button.

You seem to be assuming that your application will be in the foreground when the user "has not interacted with" your application. Most likely, that is not the case. The user will have moved to some other application (including live TV in the case of Google TV), and you will no longer be on the screen.

Its kind of screen savor.

Android does not need or use a "screen savor".