I need your help in clarifying my understanding of the various states of an app. I am going to state my interpretation - but please feel free to correct me.
1) App is launched and running in the foreground: state = UIApplicationStateActive
2) User pushes home button: state = UIApplicationStateBackground (????).
Debug stmt in my app shows it to be Active
3) User double-taps Home and kills the app: state = UIApplicationStateInactive
If the value for case 2 is indeed Active, then when is the value set to Background?
My location-based app relies on this values to take appropriate action for the user.
if ( ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) ||
([UIApplication sharedApplication].applicationState == UIApplicationStateInactive) ) {
// isInBackground = YES;
// ------ UI not available
}
else {
// isInBackground = NO;
// ------ UI is available
}
Regards,
Sam.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…