I am writing an Android application that does most of the processing in the background thread. The calculations are performed in native code using C ++. I want to update the interface with partial results during the calculations.
I can do this through JNI, namely to set a reference to a UI object in java, and then call the method of this object from native code via JNI. I am looking for a more efficient solution without any JNI calls in terms of rendering (basic setup and activation entry point must be in java).
Is it possible to completely change the executable stream from the background to the user interface in native code without using JNI (only in terms of rendering)?
Thank you for your responses. Very grateful.
EDIT:
I am considering using OpenGL to render computed content (kind of video frames) in my opinion. In this case, I probably want to use the method eglSwapBuffers()available in the EGL library since version 2.3. The biggest problem, I think, is how easy it is to switch from a background stream of "computing" to a stream of "open GL" in user code without JNI overhead. What would you suggest? Thank you for your help!
PSEUDOKOD:
Here is some kind of pseudo-code that helps illustrate what I want to achieve here. This is more like a threading issue, but the Android framework also plays a role.
void Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
jobject thiz)
{
struct result * res = calculate();
updateGL(res);
}
void updateGL(struct result * res)
{
someGLcodeWithResult(res);
eglSwapBuffers();
}
2:
, . updateGL . GLSurfaceView Java-. (setRenderer()), onDrawFrame JNI/native-. , , , JNI.
-. updateGL java/JNI ( ). , updateGL ( OpenGL) Java. ?