title: Android activity lifecycle and JNI native code lifecycle
body: <p>I have a simple app with native code. That is, an Activity plus native code. </p>
  
  <p>When the activity is entering background, I keep the native code running to do some processing. The problem is when the activity is killed by OS (due to low resource), JNI code seems to have no knowledge of what happened in Java land and still doing its job, hence wasting resource. Why does Android kill just the Activity instead of the whole process? and in this case, how does native code know that the activity was killed? OnDestroy() may not get called. </p>