> Requesting permissions in the JNI "oh you have to do that in Java" or other dumb stuff like that.
> If you want a bunch of examples of how to do a ton of things in C on Android that you "need" java for, scroll to the bottom of this file:
> https://github.com/cntools/rawdraw/blob/master/CNFGEGLDriver...
> it shows how to use the JNI to marshall a ton of stuff to/from the Android API without needing to jump back into Java/Kotlin land.
I respect this attitude but it's wrong to say Java isn't being used or executed. The truth is Java code is being called from C.
jclass ClassActivity = env->FindClass(envptr, "android/app/Activity");
jmethodID MethodrequestPermissions = env->GetMethodID(envptr, ClassActivity, "requestPermissions", "([Ljava/lang/String;I)V");
env->CallVoidMethod(envptr, activity, MethodrequestPermissions, perm_array, 0);
This code directly interfaces with the Java virtual machine. It obtains a handle to a Java class and a handle to one of its methods. Then it instructs the virtual machine to invoke the method with parameters supplied by code written in C.I searched the repository for JavaVM and JNI_CreateJavaVM and got no results. So this code is being dynamically loaded by a pre-existing Java virtual machine at runtime.