44 lines
1.4 KiB
C
44 lines
1.4 KiB
C
|
|
//#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <jni.h>
|
|
#include "jni_android.h"
|
|
#include "_cgo_export.h"
|
|
|
|
void
|
|
registerFragment(JNIEnv *env, jobject view) {
|
|
jclass cls = (*env)->GetObjectClass(env, view);
|
|
jmethodID mid = (*env)->GetMethodID(env, cls, "getContext", "()Landroid/content/Context;");
|
|
jobject ctx = (*env)->CallObjectMethod(env, view, mid);
|
|
cls = (*env)->GetObjectClass(env, ctx);
|
|
mid = (*env)->GetMethodID(env, cls, "getClassLoader", "()Ljava/lang/ClassLoader;");
|
|
jobject loader = (*env)->CallObjectMethod(env, ctx, mid);
|
|
cls = (*env)->GetObjectClass(env, loader);
|
|
mid = (*env)->GetMethodID(env, cls, "findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
|
|
jstring str = (*env)->NewStringUTF(env, "st/wow/git/logbook/Permissions");
|
|
cls = (*env)->CallObjectMethod(env, loader, mid, str);
|
|
mid = (*env)->GetMethodID(env, cls, "<init>", "(Landroid/view/View;)V");
|
|
jobject inst = (*env)->NewObject(env, cls, mid, view);
|
|
}
|
|
|
|
void CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID) {
|
|
(*env)->CallVoidMethod(env, obj, methodID);
|
|
}
|
|
|
|
jint GetEnv(JavaVM *vm, JNIEnv **env, jint version) {
|
|
return (*vm)->GetEnv(vm, (void **)env, version);
|
|
}
|
|
|
|
jint AttachCurrentThread(JavaVM *vm, JNIEnv **p_env, void *thr_args) {
|
|
return (*vm)->AttachCurrentThread(vm, p_env, thr_args);
|
|
}
|
|
|
|
jint DetachCurrentThread(JavaVM *vm) {
|
|
return (*vm)->DetachCurrentThread(vm);
|
|
}
|
|
|
|
jobject
|
|
NewGlobalRef(JNIEnv *env, jobject o) {
|
|
return (*env)->NewGlobalRef(env, o);
|
|
}
|