0

I am developing an application that will be running. In this application, if the user didn't do anything in the application within X minutes, the application will show a show a popup telling user about the inactivity of app. My question is, how can I code on detecting IDLE within X minutes?

user1619306
  • 169
  • 1
  • 5
  • 12

1 Answers1

0

I hope you are asking about an Activity being foregrounded and there is an inactivity for some time. Assuming the same here is the approach 1) In activity onresume start a timer and associate a timertask which shows a dialog (do not forget runonUIthread) 2) override 'dispatchTouchEvent' and 'dispatchKeyEvent' and in it reset the timer

In activity onpause clean up the timer

PAVAN RANGAIN
  • 85
  • 1
  • 1
  • 7
  • Can you pls provide with working example. googling has pissed me off..:'( – user1619306 Sep 02 '14 at 09:38
  • I am taking help from [Android UI example](http://stackoverflow.com/questions/4075180/application-idle-time) but it is throwing error :'( – user1619306 Sep 02 '14 at 11:08
  • E/AndroidRuntime(707): FATAL EXCEPTION: main E/AndroidRuntime(707): java.lang.ClassCastException: E/AndroidRuntime(707): at com.synchronoss.smartcare.android.twctechassist.app.MainActivity.onUserInteraction(MainActivity.java:68) E/AndroidRuntime(707): at android.app.Activity.dispatchTouchEvent(Activity.java:2094) E/AndroidRuntime(707): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675) – user1619306 Sep 02 '14 at 11:08