|
@@ -30,6 +30,7 @@
|
|
|
|
|
|
package org.godotengine.godot;
|
|
|
|
|
|
+import android.content.ComponentName;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
@@ -85,6 +86,26 @@ public abstract class FullScreenGodotApp extends FragmentActivity implements God
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public final void onGodotRestartRequested(Godot instance) {
|
|
|
+ if (instance == godotFragment) {
|
|
|
+ // HACK:
|
|
|
+ //
|
|
|
+ // Currently it's very hard to properly deinitialize Godot on Android to restart the game
|
|
|
+ // from scratch. Therefore, we need to kill the whole app process and relaunch it.
|
|
|
+ //
|
|
|
+ // Restarting only the activity, wouldn't be enough unless it did proper cleanup (including
|
|
|
+ // releasing and reloading native libs or resetting their state somehow and clearing statics).
|
|
|
+ //
|
|
|
+ // Using instrumentation is a way of making the whole app process restart, because Android
|
|
|
+ // will kill any process of the same package which was already running.
|
|
|
+ //
|
|
|
+ Bundle args = new Bundle();
|
|
|
+ args.putParcelable("intent", getIntent());
|
|
|
+ startInstrumentation(new ComponentName(this, GodotInstrumentation.class), null, args);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onNewIntent(Intent intent) {
|
|
|
super.onNewIntent(intent);
|