Ejemplo n.º 1
0
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
	JNIEnv *env;
	gJavaVM = vm;
	LOGI("JNI_OnLoad called");
	if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
		LOGE("Failed to get the environment using GetEnv()");
		return -1;
	}
	initClassHelper(env, kInterfacePath, &gInterfaceObject);
	initClassHelper(env, kDataPath, &gDataObject);
	JNINativeMethod methods[] =
			{
					{ "callVoid", "()V",
							(void *) Java_org_wooyd_android_JNIExample_JNIExampleInterface_callVoid },
					{ "getNewData",
							"(ILjava/lang/String;)Lorg/wooyd/android/JNIExample/Data;",
							(void *) Java_org_wooyd_android_JNIExample_JNIExampleInterface_getNewData },
					{ "getDataString",
							"(Lorg/wooyd/android/JNIExample/Data;)Ljava/lang/String;",
							(void *) Java_org_wooyd_android_JNIExample_JNIExampleInterface_getDataString } };
	if (android::AndroidRuntime::registerNativeMethods(env, kInterfacePath,
			methods, NELEM(methods)) != JNI_OK) {
		LOGE("Failed to register native methods");
		return -1;
	}
	return JNI_VERSION_1_4;
}
Ejemplo n.º 2
0
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void * reserved)
{
    jvm = vm;
    JNIEnv *env;
    if (vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
    {
        __android_log_print(ANDROID_LOG_ERROR, "BMW-IBus", "Failed to get environment");        
        return -1;   
    }
    
    initClassHelper(env, jReceiveCallbackClass, &jReceiveCallbackObject);

    return JNI_VERSION_1_6;
}
Ejemplo n.º 3
0
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) {
	const char * path = "com/schriek/rtmpdump/callBack";
	LOGV("Loading native library compiled at " __TIME__ " " __DATE__);
	sVm = jvm;
	JNIEnv *env;

	if ((*jvm)->GetEnv(jvm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) {
		LOGE("Failed to get the environment using GetEnv()");
		return -1;
	}

	initClassHelper(env, path, &clazz);

	return JNI_VERSION_1_4;
}
Ejemplo n.º 4
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    JNIEnv *env;
    gJavaVM = vm;
    LOGI("JNI_OnLoad called");
    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
        LOGE("Failed to get the environment using GetEnv()");
        return -1;
    }
        initClassHelper(env, kInterfacePath, &gInterfaceObject);
        
        JNINativeMethod methods[] = {
            {
                "open",
                "(Ljava/lang/String;)I",
                (void *) Java_org_sipdroid_pjlib_codec_open
            },
            {
                "encode",
                "([SI[BI)I",
                (void *) Java_org_sipdroid_pjlib_codec_encode
            },
            {
                "decode",
                "([B[SI)I",
                (void *) Java_org_sipdroid_pjlib_codec_decode
            },
            {
                "close",
                "()I",
                (void *) Java_org_sipdroid_pjlib_codec_close
            }
        };
        if(android::AndroidRuntime::registerNativeMethods(
            env, kInterfacePath, methods, NELEM(methods)) != JNI_OK) {
            LOGE("Failed to register native methods");
            return -1;
        }
    return JNI_VERSION_1_4;
}
Ejemplo n.º 5
0
jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
		JNIEnv *env;
		gJavaVM = vm;
		ALOGI("JNI_OnLoad called");
		if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
			ALOGE("Failed to get the environment using GetEnv()");
			return -1;
		}
		//Class instance caching 12b
		//ALOGI("step 1");
		initClassHelper(env, kInterfacePath, &gInterfaceObject);
		//initClassHelper(env, kDataPath, &gDataObject);
		//ALOGI("step 2");
		//Native function registration 13
		JNINativeMethod methods[] = {
		{
		"nativeSysTest",
		"(Ljava/lang/String;)I",
		(void *) Java_com_example_writetest_SysTest_nativeSysTest
		},
		{
		"copyNative",
		"(Ljava/lang/String;Ljava/lang/String;)I",
		(void *) Java_com_example_writetest_SysTest_copyNative
		},
		};

		if(android::AndroidRuntime::registerNativeMethods(
			env, kInterfacePath, methods, NELEM(methods)) != JNI_OK) {
			ALOGE("Failed to register native methods");
			return -1;
		}
		ALOGI("JNI_OnLoad finished");
		return JNI_VERSION_1_4;
}