Prevent Forge process sticking around after exiting on Android devices

This commit is contained in:
drdev
2014-06-17 01:40:25 +00:00
parent 219207e4f6
commit 77083143bd
3 changed files with 16 additions and 4 deletions

View File

@@ -35,6 +35,12 @@ public class Main extends AndroidApplication {
return;
}
initialize(Forge.getApp(getClipboard(), assetsDir), true);
initialize(Forge.getApp(getClipboard(), assetsDir, new Runnable() {
@Override
public void run() {
//ensure process doesn't stick around after exiting
android.os.Process.killProcess(android.os.Process.myPid());
}
}), true);
}
}

View File

@@ -8,6 +8,7 @@ import forge.util.Utils;
public class Main {
public static void main(String[] args) {
new LwjglApplication(Forge.getApp(new LwjglClipboard(), "../forge-gui/"), "Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true);
new LwjglApplication(Forge.getApp(new LwjglClipboard(), "../forge-gui/", null),
"Forge", (int)Utils.BASE_WIDTH, (int)Utils.BASE_HEIGHT, true);
}
}

View File

@@ -38,6 +38,7 @@ public class Forge implements ApplicationListener {
private static final ApplicationListener app = new Forge();
private static Clipboard clipboard;
private static Runnable onExit;
private static int screenWidth;
private static int screenHeight;
private static Graphics graphics;
@@ -46,9 +47,10 @@ public class Forge implements ApplicationListener {
private static KeyInputAdapter keyInputAdapter;
private static final Stack<FScreen> screens = new Stack<FScreen>();
public static ApplicationListener getApp(Clipboard clipboard0, String assetDir0) {
public static ApplicationListener getApp(Clipboard clipboard0, String assetDir0, Runnable onExit0) {
if (GuiBase.getInterface() == null) {
clipboard = clipboard0;
onExit = onExit0;
GuiBase.setInterface(new GuiMobile(assetDir0));
}
return app;
@@ -259,7 +261,10 @@ public class Forge implements ApplicationListener {
}
screens.clear();
graphics.dispose();
System.exit(0);
if (onExit != null) {
onExit.run();
}
}
//log message to Forge.log file