System.loadLibrary("bitop"); |
require("bit") |


Loves: gorkem
Loves: gorkem
Loves: atilim
void Jni_Todo(....)
{
// step 1: Get environment pointer
JNIEnv *env = 0;
int status;
int isAttached = 0;
if ((status = (*gJavaVM_guava7androidplugin).GetEnv( (void**)&env, JNI_VERSION_1_6)) < 0)
{
if ((status = (*gJavaVM_guava7androidplugin).AttachCurrentThread(&env, NULL)) < 0)
{
isAttached = 1;
}
}
// step 2: Get JAVA class pointer. For example with Java class com.gideros.android.MyActivity
jclass cls = (*env).FindClass( "com/giderosmobile/android/MyActivity" );
if (!cls)
{
if (isAttached) (*gJavaVM_guava7androidplugin).DetachCurrentThread();
return;
}
// step 3: Get JAVA function pointer. For example with Java func: static void todo()
jmethodID method = (*env).GetStaticMethodID(cls, "todo", "()V");
if (!method)
{
if (isAttached) (*gJavaVM_guava7androidplugin).DetachCurrentThread();
return;
}
//step 4: call java function
(*env).CallStaticVoidMethod(cls, method); //or others function from http://java.sun.com/docs/books/jni/html/fldmeth.html
return;
}
Loves: phongtt
Loves: chipster123, Rickyngk, SatheeshJM
JavaVM *gJavaVM_guava7androidplugin = 0;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void *res)
{
gJavaVM_guava7androidplugin = vm;
g_registerPlugin(g_pluginMain_guava7androidplugin);
return JNI_VERSION_1_6;
}
It looks like you're new here. If you want to get involved, click one of these buttons!
ar2rsawseen
2475
OZApps
1244
techdojo
1228