Fixed bug 2476 - Allow custom main() arguments
rettichschnidi I would like to pass custom arguments from my Java code (subclass of SDLActivity) to the native SDL2 binary.
This commit is contained in:
parent
7cabaebed4
commit
ec4dfdfc58
2 changed files with 51 additions and 9 deletions
|
@ -61,6 +61,16 @@ public class SDLActivity extends Activity {
|
|||
System.loadLibrary("main");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
* This method is called by SDL before starting the native application thread.
|
||||
* It can be overridden to provide the arguments after the application name.
|
||||
* The default implementation returns an empty array. It never returns null.
|
||||
* @return arguments for the native application.
|
||||
*/
|
||||
protected String[] getArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
// The static nature of the singleton and Android quirkyness force us to initialize everything here
|
||||
|
@ -277,7 +287,7 @@ public class SDLActivity extends Activity {
|
|||
}
|
||||
|
||||
// C functions we call
|
||||
public static native int nativeInit();
|
||||
public static native int nativeInit(Object arguments);
|
||||
public static native void nativeLowMemory();
|
||||
public static native void nativeQuit();
|
||||
public static native void nativePause();
|
||||
|
@ -802,7 +812,7 @@ class SDLMain implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
// Runs SDL_main()
|
||||
SDLActivity.nativeInit();
|
||||
SDLActivity.nativeInit(SDLActivity.mSingleton.getArguments());
|
||||
|
||||
//Log.v("SDL", "SDL thread terminated");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue