Handling JNI callback for Android

Hi, I am integrating third party SDK and they have a few callback. I used JNI to call their methods and everything works fine but I cannot find a way (nor example anywhere) how to handle the callbacks to be sent to the C++ code. So far what I did is to create a boolean variable and set it to true when I receive the callback and then I assign whatever information I need in other variable and within my game, for each update I check if the variable is set to true, if so, then I call a fetch method to retrieve the information I need and then set the variable back to false.

I assume this is not the best way to do it (even though it works perfectly). Anyone would have an example or point me to the best practices in that regard?

Thanks

You can study my handmade inapp purchase solution fo android, written some time ago, i think it have all you need.
https://drive.google.com/file/d/1NbuPCny7vEuQoNYYcHgO-M56iEg4lg7-/view?usp=sharing

Thanks a lot. This is awesome

This two articles also was very helpful for me: