0

I want to timeout mysession from my web service if the user doesn't use the application for >=10 minutes. If the user doesn't use the application after this delay i want my session to close. I cater with it the following way

    c = Calendar.getInstance(); 

@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    //lastActivity = new Date().getTime();

   second = c.get(Calendar.SECOND);

   Log.i("Second: ",Integer.toString(second));

    return super.dispatchTouchEvent(ev);

}

@Override
public void onResume() {

    int now = c.get(Calendar.SECOND);
    if (now - second >= 10) {
         Log.i("/******* /n TIMEOUT /n *******/",Integer.toString(now));
    }

    super.onResume();
} 

am i doing it the right way or is there a method in android to check if application is 10 minutes inactive ?

Dimitri
  • 677
  • 3
  • 19
  • 46
  • AFAIK there is no suchs method... – sandkasten May 08 '13 at 08:48
  • sandkasten is wrong I believe, but why are you trying to make an Android application behave like a web browser? What type of application are you writing? What state information does it need to remember when its UI thread resumes before and after the 10 minutes? – Stephan Branczyk May 08 '13 at 08:52

1 Answers1

0

wrong because of if second srtore at 12:12:12 and check condition on12:13:11 then what happen u have to check totaltimestamp dear

Digvesh Patel
  • 6,503
  • 1
  • 20
  • 34