Question regarding Ad Networks and JNI

Question regarding Ad Networks and JNI
0.0 0


I’ve been trying to implement ChartBoost, a purely Java based JAR Library, into Cocos2d-x.

My understanding of the framework (I am still inexperienced) is that all scenes and states for this game are coded in C*+ - meaning if I wanted to invoke an Ad at the Pause Screen, Start Menu or after level 1, I would need to use the JNI system, and call my Java method into C*+ correct?

If not, let me know and make my life easy _

If so, is there a function within Cocos to implement a Java class while passing the custom variable (ex ChartBoost CBoost; -> pass the CBoost) and invoke not only the class, but also the custom libraries from the ChartBoost SDK. Or will I have to create a separate JavaVM and Pointer and start from scratch?

Thanks so much for the response!


And I’ve figured it out - Great Code everyone You explained my answer with your Code :slight_smile:

For those who have the same questions, think Wrappers. For example, CocosDehension’s simpleAudioClass.

The simpleAudioClass pulls(wraps) the simpleAudioClassJNI which in turn pulls from the which pulls the

Wrapper wrapping a wrapper’s wrapper etc.

In this same way, you can have you declarations and variables (such as context, or custom library types) initialized and enabled before needing to pass it to the JNI - when you pass to the JNI system (with CocosDehension, or your own) you are passing a simple static item that’s ready to go - don’t need to deal with the complications.

Simple enough once you get familiar with the Cocos Framework, should have started there :slight_smile: