Android activity passing parameters to jME app


I’m starting the jME activity from another activity which needs to pass a parameter to the jME app (a .scene file to load). I can’t seem to find any means of communication between the activity invoking the jME app and the app itself. Could someone please help me with this?

1 Like

Looking at AndroidHarness I got the feeling that there’s actually no way of passing a parameter to the application before it’s started, except by replacing AndroidHarness entirely.

If I override onCreate, I must call super.onCreate. Doing anything with the app variable before will be disregarded, as it’s (re)initialized in super.onCreate, doing anything after calling super.onCreate will have happened after the app has already been started.

So my only option now is to to load the scene file after the app has been started, correct?

You can only load a scene when the app has been inited anyway, as thats when you have a valid asset manager. You can set some variable that sets the model name from the android harness to the application as described in the wiki.

Excuse me, but I still don’t see how I could pass that variable other than using a static variable or a singleton.

Related question: because I am getting this scene file on the fly (over the network), where can I store it so that the asset manager can see it? From what I understand, the asset manager is mapped to the assets folder of the application, which cannot be written to. How do I get the asset manager to read from the device’s internal or external storage?

The Android Harness can access the application. Just add an AppState that has the reference from the android side, the assetManager can register any kind of locator.

Yes, Android Harness can access the app variable (I expect that’s what you mean by application), but before calling super.onCreate, app is null, and after, app is already started.

An AppState is only called from the render thread, the code in initialize() will be called on the render thread. You can also enqueue a Callable.

After onCreate() is called you can attach an AppState or enqueue a callable that will load the .scene file

I’m afraid I can’t attach an AppState because after onCreate, the state manager is still null. I will now try enqueuing a callable and let you know how that goes :slight_smile:

Enqueuing a callable worked. Thanks, guys :slight_smile: