Skip to content

Commit

Permalink
Added an option to define libraries to be loaded on Android in a deri…
Browse files Browse the repository at this point in the history
…ved class.

This way it is no more needed to modify SDLActivity.java to add own libraries.
  • Loading branch information
philippwiesemann committed Oct 23, 2014
1 parent 775a802 commit bc382e3
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -54,18 +54,28 @@ public class SDLActivity extends Activity {
// 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);
}
}
Expand Down

0 comments on commit bc382e3

Please sign in to comment.