Android Activity Issue

Hello jme & android users,

I have a small issue, which I cant figure out…

I’m trying to create some app - purpose isn’t important - but, let’s say I want to run simple app, which you get after creating new jme3 project. I select mobile deploy and let jmeSDK create important android files.

So, Main Activity class is created, extending AndroidHarness class, which extends android.Activity class. There is constructor MainActivity, containg: appClass = “mygame.Main”; etc… just default code.

When I run this on my android device, I see classic blue cube, allowing me to move through space.

Now, what I want to do BEFORE entering the “game” (blue cube), is to run another android activity (StoreActivity, ConnectActivity, InputCreditalsActivity). Let’s say I want to store some sharedpreferences, store some files, want some important input from user… anything and then get back or run the game.

How Can I do this?



My problem is, that when I add onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);… } method to MainActivity and let it display HelloWorld, I don’ t know, how to start/re-run the game and how to create new activity the right way jme3 supports it.



Any ideas?

Thank you :slight_smile:

You shouldn’t really use the android activities as that makes your application platform dependent. If you do everything with the jme3 gui you will be able to deploy the same application to other platforms too.

Yes, but when I am developing app for mobile and pc device, I think it’s normal to customize device-dependent software packages… at least they taught us at school. Then it’s easy to switch GUI, storage options etc. parts for certain device.

I definitely agree with platform independency … but device independency quite differs :slight_smile:



I just want to know, how to design, code and deploy new activity logic and AFTER that, run the game and maybe to allow pause it, run again some android activity and get back to game :slight_smile:

thx

Yeah, I have a few cases where I’m planning to modify the way the app works specifically for the Android version…mostly the initial startup/loading screen but also areas where text entry is needed as the current nifty thing works but is a bit clumsy.



Android isn’t my first priority though so I’ve not really looked into it at all yet. I’ll be interested to see what comes out of this thread.

The AndroidHarness is built in a way so that you can even forget about it and just focus on the JME part.

But it has been also made in a way so that you can manage the activity, view layouts, and everything on the android side.

There is a layoutDisplay method that you can override and do w/e you want. There is a “frameLayout” variable that is available, but you are not forced to use it.

Then the most important part is the “view” variable that is the GlSurfaceView that contains the JME app.

Note that the JME app is initialized only once the view has been attached to a layout and displayed.



We don’t encourage this practice, because, as Normen said, it breaks the platform independence, so just be warned about that.

All of this is mentioned in the manual: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:android#using_android_specific_functions

Jme comes with all things like GUI etc., no need to use platform dependent stuff for most everything.