Browse Source

[Android] Clear memory on exit with System.exit(0)

pull/3666/head
staphen 4 years ago committed by Anders Jenbo
parent
commit
da837c4d2e
  1. 14
      android-project/app/src/main/java/org/diasurgical/devilutionx/DevilutionXSDLActivity.java

14
android-project/app/src/main/java/org/diasurgical/devilutionx/DevilutionXSDLActivity.java

@ -26,6 +26,7 @@ import java.util.Objects;
public class DevilutionXSDLActivity extends SDLActivity {
private String externalDir;
private boolean noExit;
protected void onCreate(Bundle savedInstanceState) {
// windowSoftInputMode=adjustPan stopped working
@ -49,10 +50,23 @@ public class DevilutionXSDLActivity extends SDLActivity {
if (missingGameData()) {
Intent intent = new Intent(this, DataActivity.class);
startActivity(intent);
noExit = true;
this.finish();
}
}
/**
* When the user exits the game, use System.exit(0)
* to clear memory and prevent errors on restart
*/
protected void onDestroy() {
super.onDestroy();
if (!noExit) {
System.exit(0);
}
}
private void trackVisibleSpace() {
this.getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override

Loading…
Cancel
Save