Android Kill Process Restarting Application
<p>I have a bit of a weird problem integrating a native game with a Java application in Android.</p>

<p>I have to add a native .so file for a game and wrap it with standard Activities to show a splash screen, a menu and some other stuff. </p>

<p>I notice within the native code there appears to be a kill process call. I see this in the logcat.</p>

<blockquote>
  <p>Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)</p>
</blockquote>

<p>Followed by this</p>

<blockquote>
  <p>DEBUG/Zygote(119): Process 28720 terminated by signal (11)</p>
</blockquote>

<p>This happens when I hit an exit option in the native game. When this happens the application gets restarted i.e. the Activity set as launcher in the manifest get's created in a new process. I see in logcat that the Activity manager notes the process has died and then does this:</p>

<blockquote>
  <p>INFO/ActivityManager(192): Start proc my.package.name for activity my.package.name/my.launcher.Activity: pid=28820 uid=10061 gids={3003, 1015}</p>
</blockquote>

<p>Unfortunately I can't get the native source and can't get it changed. </p>

<p>The best solution I have come up with so far is to do some kind of check in the onCreate and call finish if I think the app has been restarted. I really don't like the idea of doing that though, which is why I am posting here now. </p>

<p>Does anybody have any suggestions on a "good" way to handle this? Any ripping apart my proposed solution is also welcome. </p>

<p>I guess it's not a standard problem so the framework probably does not have much to help me here. Despite my many hours of reading docs and developing on Android I am still far form being an Android expert so any advice at all on this would be a great help.</p>

<p>EDIT:</p>

<p>Just a note, this behavior is reproducible by creating 2 Activities. The first one should launch the second. The second Activity should have a way to kill the application process such as a button that calls </p>

<pre><code>android.os.Process.killProcess(pid);
</code></pre>

<p>So if Activity A is the launcher Activity in the manifest. A starts B. B kills process. A gets started automatically by the Android OS in a different process. </p>

<p>I did this as a test to see if anything I was doing was causing the restart. The test is exactly as described with no edits to the manifest and no extra code. The restart will always happen. Just wish I could find a way to stop it from happening.</p>
