hai folks,
In Android , Native code is written as follows.
JNIEXPORT void JNICALL Java_com_android_Test_show(JNIEnv *env, jobject
obj)
{
printf("THIS IS TEST");
}
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JNIEnv *env;
JNINativeMethod meth;
jclass k;
jint r;
r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
k = (*env)->FindClass (env, "com.android.Test.show");
meth.name = "show";
meth.signature = "()V";
meth.fnPtr = Java_com.android.Test.show;
r = (*env)->RegisterNatives (env, k, &meth, 1);
return JNI_VERSION_1_4;
}
JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved)
{
JNIEnv *env;
jclass k;
jint r;
r = (*vm)->GetEnv (vm, (void **) &env, JNI_VERSION_1_4);
k = (*env)->FindClass (env, "com.android.Test.show");
(*env)->UnregisterNatives(env, k);
}
While executing on Android the following messages are obeserved in adb
logcat.
JNI ( 524): Trying to load jni .so
I/System.out( 524): /system/lib
D/dalvikvm( 524): Trying to load lib /data/libjnilibs.so 0x433f22d0
D/dalvikvm( 524): Added shared lib /data/libjnilibs.so 0x433f22d0
I/ActivityManager( 50): Displayed activity
com.android.helloactivity
But "THIS IS TEST" is not being displayed, which is displayed in
native code.
There are no errors regarding loading shared library and calling
native code.Then why is the message is not displayed in logging.
Am i doing any mistake.If JNI_OnLoad and JNI_OnUnLoad are not
implemented i am getting errors in Logging.If i do as above i not
getting that native code message.
Any help would be appreciated highly.
Regards,
-Siva.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---