title: how to determine which apps are background and which app is foreground on iOS by application id
body: <p>Using the method described in <a href="https://stackoverflow.com/questions/4312613/can-we-retrieve-the-applications-currently-running-in-iphone-and-ipad">this question</a>, I can get a list of apps running on an iOS device.
  I know PIDs and have access to their <code>kinfo_proc</code> structures.
  How can I determine which are foreground processes and which are background (assuming my app is background)?</p>
  
  <p>I tried to find this out base on information in <code>kinfo_proc</code> (see 1st link), via <code>kp_proc.p_priority</code>, but it looks like it is not possible to infer background/foreground state from priority.</p>
  
  <p>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</p>
  
  <p>I considered writing a simple <code>MobileSubstrate</code> extension, injecting it into all apps and just hook everyone's <code>applicationDidBecomeActive</code>, but this requires a jailbreak and is too invasive.</p>