Question

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 ?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top