I cannot create an options menu with the jme sdk. Should onCreateOptionsMenu and onPrepareOptionsMenu work?


Nifty is not a viable option on Android imo. When I’ve tried to use it, even with only a couple of buttons, the fps goes down to a crawl (something like 4fps with a couple of buttons). I’ve had to create guiNode UIFs with pictures and mouse click coordinate checking to keep the app runnable on both platforms. There’s been a few threads posted about Nifty running too slow on Android to be useful as a UIF.

I tried to connect the profiler in Netbeans to a Nifty test project to try to figure out why it boggs down the app, but I couldn’t figure out how to get the profiler to work while running the project with the android configuration. It always popped up the PC version of the project.

Until Nifty can be optimized for Android, I don’t see how to use it on that platform.

@jawfin I assume you mean that you inflate the XML on the android side as a seperate activity? If so, how did you get the menu button detection working? I had to create a listener between the android activity and the simpleapplication class because I could figure out how to register the inputmanager to call the android activity class without making the whole applicaiton android specific.

I’ve seen the same thing. I’ve never investigated why. I do know that the engine intercepts all key touches, so I’m not sure that even if the onCreateOptions and onPrepareOptions run, the menu key touch event probably won’t be recognized by the activity either (ie. options menu probably won’t appear).

Thanks for your response. I’ll watch this thread to see if anyone chips in with a fix or more information.


This doesn’t really answer the question as it stands, but I dislike the default menu and I created my own. That the default only hold six items is ridiculous - imagine a tablet landscaped, like 7 inches of screen across and each button is bigger than an inch, but it won’t hold a 7th button for you.

What I’ve done is created a xml layout that has buttons at the bottom (custom background to look like the menu) and the rest of the layout 100% transparent. On detection on the menu key I show the layout.

I’d suggest simply using nifty menus, these will work on other platforms too.

That bad performance is only true for some devices (mainly those that would not run games too well anyway) and as stated we are aware of that and the performance has already been improved lately. Generally using nifty is the better solution when you look for best cross-platform compatibility. Remember we aim to add iOS and probably other platforms to the deployment options at some point and only applications that are laid out as we suggest will benefit from that.

My device is a dual core Motorola Bionic. I can’t believe it would be considered a bad performing device. I agree that it would be better to use Nifty for cross platform compatibility, but I haven’t seen any performance improvements that you are referring to. Last time I ran my test project, I believe I went from 60fps without Nifty to about 4fps with Nifty enabled with a couple of buttons.

If I update the SDK nightly and run the nifty test project again, you think I shouldn’t have performance issues? I thought I just retried this not that long ago, but I can try again. I’ll run the test project again and I’ll post the code, xml and performance results.

Is there anyone running Nifty on Android while keeping the framerate at somewhere around 20-30fps?

Yes there is, there even was before the changes. And the changes were not yet added to the stable version. The improvements are even noticeable on desktop but I cannot say anything about your device. You don’t have to believe anything, you told me yourself it performs bad.

I would love to know who they are so I can ask them for an example. For the life of me, I can’t imagine how that is possible based on what I saw, but I hope that it is something to do with how I do it.

I don’t quite understand what you meant by “You don’t have to believe anything, you told me yourself it performs bad.” My point was that the Motorola Bionic is supposed to be one of the better hardware platforms for Android phones. I’m not sure what phones have better hardware. If “That bad performance is only true for some devices (mainly those that would not run games too well anyway)”, then I’m not sure what hardware specs are expected for jME apps to run on Android.

I’m a big supporter of jME and I have a lot of respect for what the team has done, but the Nifty topic still baffles me. I will run the test project again based on the latest nightly as I said and post the results.

If you can, please let me know who is running Nifty on Android succesfully so I can figure out why it is not on my stuff.

@nehon has run his nifty GUI at 60fps on his tablet for example. Theres nothing different about other nifty guis ^^ I do not disagree with you that nifty performs not so well on some devices (like yours for example) but its not just a question of raw GPU power, android itself has various performance issues that express themselves less or more depending on hardware and android version. However the frames per second performance of a UI is just part of the whole picture and using nifty GUI is the best solution overall, hence I openly disagree with you when you close a thread basically saying “nifty sucks, keep your hands off it”.

By no means was I saying “nifty sucks, keep your hands off it”. I’ve seen the GUIs designed for the beta contest entries and I am very impressed. However, everytime I tried to run Nifty on the Android phone, I got very poor results and every post I created to point this out got basically no response. So that lead me to believe that Nifty had bad performance on Android. I was just sharing that opinoin.

As promised, I went back and reran my simple nifty test on the latest stable SDK build. As you promised, Nifty has been greatly improved on Android. I was shocked to see a simple 5 button GUI running at 22fps on my phone now, where a 1 button GUI was running at 4fps last time. I appologize for what I said before if I hurt anyones feelings, but I was sharing my experience. Apparently, the improvements you mentioned were indeed substantial.

With this I will definetly try to use Nifty for what I am working on.

Now, with that being said, I still have one of the original problems I had before with the mouse click position (or Touch Event in this case) not being communicated to the Nifty system. This means that when the button is clicked with the mouse on the PC version, the button even is fired. When the button is touched on the Android device, nothing happens.

When I touch one of the 5 buttons on the GUI on Android, I get the following:

21:12:22.055 23515 com.mycompany.mygame INFO tyInputEventHandlingLog [processMouseEvent] [0, 0, 0, 0, true] processed [false]

I believe I pointed this out in http://hub.jmonkeyengine.org/groups/android/forum/topic/error-with-nifty-and-awt/. The end of the thread talks about the mouse position not being updated on touch events (or simulated mouse clicks in this case).

@nehon, are you using a modified engine to get nifty to run on Android?

No, he’s using vanilla nifty.

I don’t use a modified engine…

the thing is, Nifty has descent fps on android as long as you use plain bitmap or text.

Once you use fancy controls (buttons, listbox, etc), fps starts to severely drop.

I only use image with interacts and it’s ok.

I did made the nifty demo run at 60, but again, once the controls pops in, it drops at 22 or so. (note that the demo as no 3D scene behind it).

The problem is not really Nifty IMO, the hardware is to blame. Even very recent tablets have very weak GPU, the fill rate is very low.I had to severly lower my expectations for the “game” i’m making on my tablet.

Edit : On a side note, I’m not notified anymore when I’m mentioned in a post with @nehon

I understand about the images vs buttons.

I noticied that you committed a change for the mouse position on touch to be communicated to Nifty (Thanks). How was your interact working before? How did it recognize the user clicked on it if Nifty wasn’t getting the mouse position?

@iwgeric said:
How was your interact working before?

It wasn't at all... :p
I guess the x and y were always 0
your fix works fine really