Allow overriding the main entry point on Android
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java
index 79a371d..5d7e81d 100644
--- a/android-project/src/org/libsdl/app/SDLActivity.java
+++ b/android-project/src/org/libsdl/app/SDLActivity.java
@@ -74,6 +74,29 @@ public class SDLActivity extends Activity {
protected static AudioRecord mAudioRecord;
/**
+ * This method returns the name of the shared object with the application entry point
+ * It can be overridden by derived classes.
+ */
+ protected String getMainSharedObject() {
+ String library;
+ String[] libraries = SDLActivity.mSingleton.getLibraries();
+ if (libraries.length > 0) {
+ library = "lib" + libraries[libraries.length - 1] + ".so";
+ } else {
+ library = "libmain.so";
+ }
+ return library;
+ }
+
+ /**
+ * This method returns the name of the application entry point
+ * It can be overridden by derived classes.
+ */
+ protected String getMainFunction() {
+ return "SDL_main";
+ }
+
+ /**
* This method is called by SDL before loading the native shared libraries.
* It can be overridden to provide names of shared libraries to be loaded.
* The default implementation returns the defaults. It never returns null.
@@ -1218,17 +1241,12 @@ class SDLMain implements Runnable {
@Override
public void run() {
// Runs SDL_main()
- String library;
- String[] libraries = SDLActivity.mSingleton.getLibraries();
- if (libraries.length > 0) {
- library = "lib" + libraries[libraries.length - 1] + ".so";
- } else {
- library = "libmain.so";
- }
- String function = "SDL_main";
+ String library = SDLActivity.mSingleton.getMainSharedObject();
+ String function = SDLActivity.mSingleton.getMainFunction();
+ String[] arguments = SDLActivity.mSingleton.getArguments();
Log.v("SDL", "Running main function " + function + " from library " + library);
- SDLActivity.nativeRunMain(library, function, SDLActivity.mSingleton.getArguments());
+ SDLActivity.nativeRunMain(library, function, arguments);
Log.v("SDL", "Finished main function");
}