title: How to measure time elapsed of another app? (in low memory situations)
body: <p>I am making an application that launches games (apps not made by me), and I have to measure the time elapsed of each game session for business requirement.</p>
  
  <p>However, my app is killed if a large game launch and low memory occurs.</p>
  
  <p>I have tried to start a long-running service, which runs a handler monitoring the package name of the foreground activity, and keep the service running at least as long as the game I launched by returning <code>START_STICKY</code>, using <code>startForeground()</code>, running on a separate process, but with no luck. </p>
  
  <p>I tried to send broadcast in <code>onDestory()</code>, but it is not called. </p>
  
  <p>I have the platform signature and can have my app run as system app by adding <code>android:sharedUserId="android.uid.system"</code>, but does it help?</p>
  
  <p>Or is there better approach to do the measurement? Thanks!</p>