From 0701276b4fec856d5427e4776eec3cc7c56ec065 Mon Sep 17 00:00:00 2001 From: yy1717 <fctom1215@outlook.com> Date: 星期二, 25 八月 2020 17:51:10 +0800 Subject: [PATCH] 坐标 --- lib/src/main/cpp/native-lib.cpp | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/lib/src/main/cpp/native-lib.cpp b/lib/src/main/cpp/native-lib.cpp index 5204dd3..1f47779 100644 --- a/lib/src/main/cpp/native-lib.cpp +++ b/lib/src/main/cpp/native-lib.cpp @@ -251,6 +251,35 @@ return id; } +void PlayRing(void) +{ + JNIEnv *env; + bool ready_in_java_env = false; + + if (sg_jvm->GetEnv((void **)&env, JNI_VERSION_1_6) != JNI_OK) { + // Attach涓荤嚎绋� + if (sg_jvm->AttachCurrentThread(&env, NULL) != JNI_OK) { + LOGE("%s: AttachCurrentThread() failed", __FUNCTION__); + return; + } + } else { + ready_in_java_env = true; + } + + jclass cls = env->GetObjectClass(sg_obj); + jmethodID fun = env->GetMethodID(cls, "PlayBreakRing", "()V"); + + env->CallVoidMethod(sg_obj, fun); + + env->DeleteLocalRef(cls); + + if (!ready_in_java_env) { + //Detach涓荤嚎绋� + if (sg_jvm->DetachCurrentThread() != JNI_OK) { + LOGE("%s: DetachCurrentThread() failed", __FUNCTION__); + } + } +} extern "C" JNIEXPORT void JNICALL Java_com_anyun_exam_lib_RemoteService_startNative(JNIEnv *env, jobject thiz) { -- Gitblit v1.8.0