android_jni.h
The JNI an Android app's C++ uses -- the activity, its thread's JNIEnv, and the SDK's own Java class.
#include <sonore/android_jni.h>- 7other declarations
- Guides: Getting started, Platforms and formats
On this page
Design notes
The framework is reached through JNI on its own classes (android_app.h asks for the density, the insets, the permissions that way). What only Java can do -- implement a framework callback interface -- is in SonoreBridge (sdk/android/java), which sonore_add_standalone compiles into the APK's classes.dex. FindClass from native code searches the SYSTEM class loader, which has never heard of an app's own classes, so SonoreBridge is loaded through the activity's class loader instead, once, and kept.
Every call here is for the activity's main thread unless it says otherwise: that is the thread whose JNIEnv the activity hands over.
Functions 7
- fn
inline ANativeActivity*& currentActivity()The activity this process is showing, while it shows one.android::currentActivity · android_jni.h:28 - fn
inline JNIEnv* env()The main thread's JNIEnv: the one every activity callback runs on.android::env · android_jni.h:34 - fn
inline bool failed(JNIEnv* e)Whether a Java exception is pending; cleared either way, so one failed call never poisons the next.android::failed · android_jni.h:41 - fn
inline JNIEnv* envForThisThread()A JNIEnv for THIS thread, attaching it to the VM if it is not yet: for a callback Java makes on a thread of its own.android::envForThisThread · android_jni.h:49 - fn
inline jclass bridgeClass()com.sonorie.sonore.SonoreBridge, through the activity's class loader, as a global reference; null when the APK carries no classes.dex (a build without a JDK, or the command-line program, which has no activity at all).android::bridgeClass · android_jni.h:63 - fn
inline bool registerNatives(const JNINativeMethod* methods, int count)Bind native implementations to SonoreBridge's native methods. False when there is no SonoreBridge, or it does not declare them.android::registerNatives · android_jni.h:94 - fn
inline std::string utf8(JNIEnv* e, jstring s)A Java string, as UTF-8.android::utf8 · android_jni.h:104