Handlers and the jME3 activity

I have my jME3 graphics correctly running in the created Android project and I can successfully communicate between the jME3 update loop and information on the “android side” via an AppState. I am currently trying to run GPS in the background and I am having a problem understanding what happens once jME3 “takes over” the Android device. From what I understand, in standard Android development you make Activities and swap between them. I assume that AndroidHarness turns the jME3 project into an Activity and that Activity takes over everything. What’s the best way to do something in the background (like collecting GPS data in my case)? Should I make a thread in MainActivity or make a Handler? Do I need a thread for the GPS gathering and put the jME3 project in its own thread as well? Looking through AndroidHarness, the jME3 app invokes .start() inside of onCreate, so do I need to connect to the GPS before this takes over?


jME3 runs in the OpenGL thread which is separate from any other Android threads. If you’re gathering data via GPS you’re probably doing it in a separate thread, in that case you can use standard multithreading primitives to transfer data over between threads.

You might want to take a look at this thead: