-4

In my new app i need to manage time while the user is not in the app.

For example, when the user leaves the app and comes back an hour later, a task they wanted done is now done after that hour.

What is the best way to make this happen?

coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118
  • 2
    What is the problem? You save the task end time and in `onResume()` or so you compare it to the actual time. – SimonSays May 21 '14 at 23:22

1 Answers1

2

Making data persistent in android Like Simon said, store a timestamp when app closes or your task is started then when you resume compare it to that time stamp to discover the elapsed time.

Community
  • 1
  • 1
Dave S
  • 3,378
  • 1
  • 20
  • 34
  • Thats a good way to do it. The only problem i can see with this us..What if the user leaves the app at a certain time stamp like 2:00am. then come back to the app at exactly 2:00pm. That means the time stamp will be the same right? This means nothing will happen even though 12 hours have lapsed. – coder_For_Life22 May 21 '14 at 23:34
  • http://stackoverflow.com/questions/5369682/get-current-time-and-date-on-android I don't believe timestamps reset every 12, or even every 24 hours but you can use a Calendar, a Date or something else, there are many ways to get the time. – Dave S May 21 '14 at 23:49