title: Can I detect if Android has killed the application (task process) from a Notification Intent / PendingIntent?
body: <p>The Android OS kills processes when it's low on memory. Scenario: Android kills the app process and I re-open it through either the Android launcher or the recent-task list (long press home button). I can check if Android killed my app process in the onCreate() method of the most recently viewed activity using:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
  
      if (savedInstanceState != null) {
          // Re-initialise things that killing the app would have destroyed
      }
  }
  </code></pre>
  
  <p>However, if Android kills the app process and I re-open it through a Notification using an Intent packaged inside a PendingIntent, I don't know how to determine if the app process was killed by Android. Subsequently I do not re-initialise things that killing the app process would have destroyed. </p>
  
  <p><strong>Is there a way to determine if Android killed the application process when opening a new Activity from a Notification?</strong> </p>
  
  <p>I have found one hacky solution to this problem. Using: <a href="https://stackoverflow.com/questions/8655388/android-always-launch-top-activity-when-clicked-on-notification">Android: always launch top activity when clicked on notification</a> I can open the activity on top of the stack which is passed a savedInstanceState if Android killed the app process and deal with re-initialisation. Each activity is then responsible for redirecting the user to the appropriate activity using Extras in the original Notification Intent. Intent setup for this scenario is below:</p>
  
  <pre><code>Intent notificationIntent = new Intent(this, MainActivity.class);
  notificationIntent.setAction(Intent.ACTION_MAIN);
  notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  </code></pre>
  
  <p><strong>Is there an Action, Category or Flag I can set on an Intent that will emulate re-opening the app process as if done by the user but on a new Intent / Activity?</strong></p>
  
  <p><strong>EDIT:</strong> To clarify the last question (although it seems my infant understanding of Android is failing me so it probably doesn't make sense): Is there an Action, Category or Flag I can set on an Intent, like in the snippet above, that will allow me to determine if the app process has been killed by the OS?</p>