Using the method described in this question, I can get a list of apps running on an iOS device. I know PIDs and have access to their kinfo_proc structures. How can I determine which are foreground processes and which are background (assuming my app is background)?

I tried to find this out base on information in kinfo_proc (see 1st link), via kp_proc.p_priority, but it looks like it is not possible to infer background/foreground state from priority.

I don't really care if this works correctly for AppStore Review but I would prefer a method that will work without a jailbreak(i.e. Private APIs are ok but which ones?). I want this to work at least on iOS 5

I considered writing a simple MobileSubstrate extension, injecting it into all apps and just hook everyone's applicationDidBecomeActive, but this requires a jailbreak and is too invasive.

Edit
Report