That simplicity explains why so many people use AsyncTasks. But it also comes with a severe pitfall: a risk for memory leaks. It’s not the AsyncTask in itself that’s the risk but the fact that this class is so simple to use that you could easily throw a little anonymous class in your Activity to do the job and not realize how wrong what you just did is: if you implement an AsyncTask as an inner class or an anonymous one, your task will keep an implicit reference to the enclosing class, that is your activity. This means that your activity can’t really be destroyed and garbage collected in case of a device rotation (or any other configuration change) until that background task is finished.
It’s possible that a device may not have internet access, nor GPS, and just recently rebooted–invalidating Tempo’s cache. In that situation, your only choice is to use the
System.currentTimeMillis() as a fallback strategy.