SDLActivity NDK communicating with C++

I know this might be out of scope but I don’t know who has experience with SDLActivity and calling ad’s when C++ code is certain state.

I want to call ads if a bool is true, disable the ad when the bool is false.

You can call into Java code using the JNI. The JNI requires a JNIEnv ptr
and possibly an activity class or possibly an object. You can access these
via SDL:

https://wiki.libsdl.org/SDL_AndroidGetJNIEnv

Note that you are on the game thread and not your UI thread when running
your native code. Depending on how your Ad SDK is set up, this may cause
concurrency issues which you must address. The Android Readme explains the
threading situation.

You can get blocks of Java code to run on the ui thread by using
runOnUiThread. It is a well documented thing across the web, used in more
Android places than just SDL game development.

Michael LabbeOn Mon, Feb 1, 2016 at 4:47 PM, Timodor wrote:

I know this might be out of scope but I don’t know who has experience with
SDLActivity and calling ad’s when C++ code is certain state.

I want to call ads if a bool is true, disable the ad when the bool is
false.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks for this information, I did get working using your information. With Help of Friend all we had to do was create a Java Function in SDLactivity.java and it worked. But Still having bugs with the threads.