1 #include "jniutils.h"
2 #include <jni.h>
3 #include "SDL.h"
4 
5 #define ACTIVITY_CLS_NAME "GameActivity"
6 
jniutils_vibrate_device()7 void jniutils_vibrate_device()
8 {
9   // retrieve the JNI environment
10   JNIEnv  *env = (JNIEnv*)SDL_AndroidGetJNIEnv();
11 
12   // retrieve the Java instance of the GameActivity
13   jobject activity = (jobject)SDL_AndroidGetActivity();
14 
15   // find the Java class of the activity. It should be GameActivity.
16   jclass cls = env->GetObjectClass(activity);
17 
18   // find the identifier of the method to call
19   jmethodID method_id = env->GetStaticMethodID(cls, "jni_vibrate", "()V");
20 
21   // effectively call the Java method
22   env->CallStaticVoidMethod(cls, method_id);
23 
24   // clean up the local references
25   env->DeleteLocalRef(cls);
26   env->DeleteLocalRef(activity);
27 }
28 
29