summaryrefslogtreecommitdiff
path: root/android-project
diff options
context:
space:
mode:
authorSylvain Becker <sylvain.becker@gmail.com>2019-01-07 17:06:50 +0100
committerSylvain Becker <sylvain.becker@gmail.com>2019-01-07 17:06:50 +0100
commite6fe64e4dc78fd88877ef998b8ac4024bfa02f5a (patch)
tree3db4bdca86316908b26a9fd472291c66cef3c779 /android-project
parent3b966c66ff62d197fa908fde3fc3dc0b4bec4939 (diff)
Android: don't allow multiple instance of SDLActivity
Default launch mode (standard) allows multiple instances of the SDLActivity. ( https://developer.android.com/guide/topics/manifest/activity-element#lmode ) Not sure this is intended in SDL as this doesn't work. There are static variables in Java, in C code which make this impossible (allow one android_window) and also Audio print errors. There is also some code added in onDestroy as if it would be able to re-initialize: https://hg.libsdl.org/SDL/rev/56e9c709db7e Bug Android activity life-cycle seems to show there is not transition to get out of onDestroy() https://developer.android.com/reference/android/app/Activity#ActivityLifecycle ( can be tested with "adb shell am start my.package.org/.MainActivity" and "adb shell am start -n my.package.org/.MainActivity" ) Send me a message if there are real use-case for this !
Diffstat (limited to 'android-project')
-rw-r--r--android-project/app/src/main/AndroidManifest.xml2
-rw-r--r--android-project/app/src/main/java/org/libsdl/app/SDLActivity.java14
2 files changed, 5 insertions, 11 deletions
diff --git a/android-project/app/src/main/AndroidManifest.xml b/android-project/app/src/main/AndroidManifest.xml
index 25730cf39a..e994e46b7e 100644
--- a/android-project/app/src/main/AndroidManifest.xml
+++ b/android-project/app/src/main/AndroidManifest.xml
@@ -54,6 +54,8 @@
<activity android:name="SDLActivity"
android:label="@string/app_name"
+ android:alwaysRetainTaskState="true"
+ android:launchMode="singleInstance"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
>
<intent-filter>
diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 71db555263..ac8515d01f 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -386,8 +386,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
if (SDLActivity.mBrokenLibraries) {
super.onDestroy();
- // Reset everything in case the user re opens the app
- SDLActivity.initialize();
return;
}
@@ -405,15 +403,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
} catch(Exception e) {
Log.v(TAG, "Problem stopping thread: " + e);
}
- SDLActivity.mSDLThread = null;
-
- //Log.v(TAG, "Finished waiting for SDL thread");
}
super.onDestroy();
-
- // Reset everything in case the user re opens the app
- SDLActivity.initialize();
}
@Override
@@ -1711,12 +1703,12 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
return;
}
- /* Surface is ready */
- SDLActivity.mIsSurfaceReady = true;
-
/* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */
SDLActivity.onNativeSurfaceChanged();
+ /* Surface is ready */
+ SDLActivity.mIsSurfaceReady = true;
+
SDLActivity.mNextNativeState = SDLActivity.NativeState.RESUMED;
SDLActivity.handleNativeState();
}