v0.9.1: (hopefully) fixed some edge case bugs with android lifecycle
This commit is contained in:
parent
04addf7cbb
commit
8c1372aa27
|
@ -28,6 +28,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
|
||||
import com.badlogic.gdx.Files;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
|
@ -115,6 +116,38 @@ public class AndroidGame extends AndroidApplication {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
//prevents weird rare cases where the app is running twice
|
||||
if (instance != this){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
finishAndRemoveTask();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
//LibGDX itself doesn't clear these in every case, so we do it ourselves to be sure
|
||||
graphics.clearManagedCaches();
|
||||
audio.dispose();
|
||||
Gdx.app = null;
|
||||
Gdx.input = null;
|
||||
Gdx.audio = null;
|
||||
Gdx.files = null;
|
||||
Gdx.graphics = null;
|
||||
Gdx.net = null;
|
||||
|
||||
if (instance == this) {
|
||||
instance = null;
|
||||
view = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
//do nothing, game should catch all back presses
|
||||
|
|
Loading…
Reference in New Issue
Block a user