Added an option to define libraries to be loaded on Android in a derived class.
authorPhilipp Wiesemann <philipp.wiesemann@arcor.de>
Thu, 23 Oct 2014 16:45:18 +0200
changeset 9183 9a0ebeef4988
parent 9182 d1bf8c7a532e
child 9184 741700a12835
Added an option to define libraries to be loaded on Android in a derived class. This way it is no more needed to modify SDLActivity.java to add own libraries.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Thu Oct 23 16:41:01 2014 +0200
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Thu Oct 23 16:45:18 2014 +0200
@@ -54,18 +54,28 @@
     // Audio
     protected static AudioTrack mAudioTrack;
 
+    /**
+     * 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.
+     * An array returned by a new implementation must at least contain "SDL2".
+     * Also keep in mind that the order the libraries are loaded may matter.
+     * @return names of shared libraries to be loaded (e.g. "SDL2", "main").
+     */
+    protected String[] getLibraries() {
+        return new String[] {
+            "SDL2",
+            // "SDL2_image",
+            // "SDL2_mixer",
+            // "SDL2_net",
+            // "SDL2_ttf",
+            "main"
+        };
+    }
+
     // Load the .so
     public void loadLibraries() {
-       String AppLibraries[] = {
-         "SDL2",
-         // "SDL2_image",
-         // "SDL2_mixer",
-         // "SDL2_net",
-         // "SDL2_ttf",
-         "main"
-       };
-
-       for (String lib : AppLibraries) {
+       for (String lib : getLibraries()) {
           System.loadLibrary(lib);
        }
     }