How to pass parameter to the 01_HellowWorld (urho3d app) from android activity (LauncherActivity.kt)


i have a string of user’s profile in anddroid LauncherActivity

i want paas it to a urho app


im sorry i cant advise yet, but i am getting there rapidly - within two weeks I guess, I will have an android build

1 Like

There is @Lumak repositories on Github which provide samples for that.

See the ServiceCmd class for more details.


i can invode function between activity and .so through jni.
i want a urho3d ‘offical’ solution .

 * 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() {
    // Urho3D: the default implementation returns the "app_process" as the first argument instead of empty array
    return new String[]{"app_process"};

this is a graceful solution


Yes. Just remember that Urho3D engine expects the arguments in the same format as other platforms. i.e. Arg 0th in the array for the name of the program/process, arg 1st is the first argument from the app’s perspective, and so on.

1 Like

Spent last few days working with the Android build system and came across the same issue. I see that the engine doesn’t support out of the box solution how the custom events could be handled between the Android app and the Urho application at runtime. Shouldn’t we think of a way how to implement this in the engine core? Basically implementing the same thing that @Lumak achieved and adding some sort of documentation how to use it.


Personally I don’t see what’s wrong with the current approach of how Application and Engine classes handles the parameters.


No, I mean when the application is actually running and I need to send some sort of events back and forth for ads, login events etc. and I would like to keep the game running in the background and waiting for specific events.

1 Like

I guess it’s a different topic then. I have no comment on that.


You can use custom events, which are handled by your gamestate implementation(s) via your gamestatemanager fsm…
Well, that’s how I handled things in my gamestate manager. High-level requests are monitored by gamestatemanager, which operates in the background, and owns in my case, four states - intro, loading, menu and gameplay (all remain resident, but usually, only one is active). Next level down, the gamestate implementations for each major state have a chance to monitor for custom events too, and finally, in the custom urho component classes, we can do this one more time, so there are many levels at which we can take control. It’s a lot of control.

I chose to make my game overlord object be derived from Urho’s object class, so that it can deal with events…

    class GameStateManager : public Object
        URHO3D_OBJECT(GameStateManager, Object);

        /// Factory Function
        static void RegisterObject(Context* context){

The short answer is - create a background layer object that owns the game scene, and possibly other scenes too - I can show you my pattern for a game state machine for urho that handles a custom event: request for change game scene, and has a handler for handling notification of scene change completion


There is a long answer too.
Here is my current top level code.
The application object is the top level object.
Under it, lives our state manager, and under that, the game states.

class MyApp : public Urho3D::Application

    WeakPtr<Scene> mgrscene_;
    WeakPtr<Scene> gamescene_;
    WeakPtr<Text> text_;
    WeakPtr<Node> cameraNode_;
    SharedPtr<GameState::GameStateManager> handler;

    MyApp(Context* context) :
    virtual void Setup()
        // Called before engine initialization. engineParameters_ member variable can be modified here
    virtual void Start()

        // Engine has FPS capped at max. 200
        // Let's remove that cap for debug purposes

        // Register the AngelScript subsystem (a non-core subsystem)
        context_->RegisterSubsystem(new Script(context_));

        // Create 'Manager Scene' and 'Game Scene'
        mgrscene_  = new Scene(context_); mgrscene_->SetName("Manager Scene");

        // Create GameState Manager
        // This will register all relevant classes
        handler = new GameState::GameStateManager(context_);

        // Initialize GameState Manager
        // This will instantiate all gamestate classes

        // Register application handlers for "Core Events":
        // E_BEGINFRAME                 (Start of frame event)
        // E_UPDATE                     (Logic update event, usually used to do "normal" stuff each frame)
        // E_POSTUPDATE                 (Logic post-update event)
        // E_RENDERUPDATE               (Render update event)
        // E_POSTRENDERUPDATE           (Post-render update event)
        // E_ENDFRAME                   (End frame event)
        // See for a complete list of possible events
        SubscribeToEvent(E_KEYDOWN,URHO3D_HANDLER(MyApp,HandleKeyDown)); // we're just watching the ESCAPE and TAB keys here

        // Set mouse behaviour


Amusingly, I don’t actually use the gamescene defined in this class - gameplaystate is a substate of the gamestate manager, so some redundant code here but you get the idea


I was talking about events between Java and C++, I know how to send a command from C++ to Java but not the other way around. I see that Lumak updated the SDL library in the engine to support additional method which would process custom events between C++ and Java but the code at the moment is not a part of the engine and I would like to change that.