On Sep 17, 11:22 pm, Sridhar M <sridhar....@gmail.com
> This link gives a comprehensive way of how callbacks into JAVA are done from
> native lib.
(I removed the asterisks from the URL.)
The stuff on page 8 suggests some confusion about caching class
objects in local references, as well as the finer points of FindClass
and class loaders (which is a bit complicated). I'm also not a fan of
perpetually attaching and detaching native threads unless it's
happening infrequently, so I don't know how closely I'd follow the
It uses android::AndroidRuntime::registerNativeMethods(), which isn't
part of the NDK. Of course, this was written before the NDK was
released, so that's understandable. (The JNI RegisterNatives function
should be used.)
This is another instance of someone thinking JNI_OnLoad is mandatory.
(I think I'd better re-phrase the debug message that's displayed when
it's not there -- too many people have made this mistake.) JNI for
Android is like JNI for any other VM.
In general the document is interesting, but some of the commentary is
misleading, and I think most people will be better served by samples
from the Android source tree (especially since the last page of the
doc points out that the examples cause the app to crash if you hit the
"back" button and then restart the activity).
As usual, I recommend reading the JNI spec and some of the Android
sample code, and then carefully reading the JNI Tips document.