calling android_main(struct android_app* state) manually?

2.7k Views Asked by At

I am using powervr sdk to draw 3d models on top of my camera view which is created using the vuforia engine.

the entire powervr code is completely native and is called by the android_app_glue. To begin rendering, android_main(struct android_app* state) is called. I want to call this function myself from one of my native functions instead of having it being called onCreate of some NativeActivity.

1

There are 1 best solutions below

0
On

Android activity life cycle is done in Java, and android_main (unlike main on Linux/OS X/Windows) is not called by the OS, instead it is called by the Native App Glue, which consists of android.app.NativeActivity in Java and android_native_app_glue.c in the main library and proxies the events to a separate thread in your native library.

The glue is provided only for convenience, you are free not to use the glue at all and to reimplement the functionality by yourself, or you can modify/extend the glue.

So, if you want to use the glue, you may remove the android_main call from android_native_app_glue.c, but make sure the glue is initialized properly before you make your own call to android_main.