简体   繁体   中英

Communicating between Android and NativeActivity

I am working on an android app where I have a 3D part with most of the app's functionallity written in C++ using ogre. Some features (like the UI for search etc) are implemented using normal android UI. Up until now I used JNI for communicating between those two and directly started the rendering thread from java and managed it from there. However this leeds to some very messy code.

Now Ive stumbled across NativeActivity with its own thread and really like it. However - I still need to initiate some procedures in the rendering engine from java and the other way around. For this I would like to be able to send events to the native code that are handled like sensor event in the NativeActivity's thread. To initiate Java procedures from C++ I could simply perform JNI calls and post them on the UI thread (im open for sugestions if anyone has a better idea).

So the main question is: Is there a way I can (in Java) pass the NativeActivity some event-like objects that are then handled in my main native loop inside the NativeActivity using C code?

Thanks in advance!

您可以在jni方法中传递jObject并将其处理到c / c ++代码中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM