React Native Android restart app when crashes
<p>I'm working on an that needs to run in Kiosk Mode. I think I have covered every possible way so the user cannot leave the app, but I want some sort of safety net: in case the app crashes I need it to restart automatically.</p>

<p>I've been looking at guide on how to do it, but I haven't found one that I could translate to React Native.</p>

<p>I found <a href="http://chintanrathod.com/auto-restart-application-after-crash-forceclose-in-android/" rel="nofollow">this</a> article particularly useful. However, I cannot replicate it entirely due to the fact that in React Native there isn't a .java Application file (or at least I haven't found one), so I can override the UncaughtExceptionHandler.</p>

<p>I can restart the app programmatically by calling this method:</p>

<pre><code>public void restartApp(){
    Intent i = getBaseContext().getPackageManager()
        .getLaunchIntentForPackage( getBaseContext().getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
    | Intent.FLAG_ACTIVITY_CLEAR_TASK
    | Intent.FLAG_ACTIVITY_NEW_TASK);

    startActivity(i);
}
</code></pre>

<p>But I simple cannot call it when the app crashes.</p>