+- (void) applicationDidEnterBackground:(UIApplication *)application {
+ if (kCFCoreFoundationVersionNumber < 1000 && [self isSafeToSuspend])
+ return [self terminateWithSuccess];
+ [self saveState];
+}
+
+- (void) applicationWillEnterForeground:(UIApplication *)application {
+ NSDate *closed = [Metadata_ objectForKey:@"LastClosed"];
+ if (closed == nil)
+ return;
+
+ NSTimeInterval interval([closed timeIntervalSinceNow]);
+
+ if (interval <= -(30*60)) {
+ [tabbar_ setSelectedIndex:0];
+ [[[tabbar_ viewControllers] objectAtIndex:0] popToRootViewControllerAnimated:NO];
+ }
+
+ if (interval <= -(15*60)) {
+ if (IsReachable("cydia.saurik.com")) {
+ [tabbar_ beginUpdate];
+ [appcache_ reloadURLWithCache:YES];
+ }
+ }
+}
+