--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
I'm bumping this because I'm having a similar issue using native app...From my native app, I'd like to fire a standard android activity using an Intent... problem, I need to get the class of my activty, but the classloader can't resolve it when I'm doing a FindClass from the native app thread...Id like to use a SQLite database also in the native app, and to not have to write all the Java code using JNI, I created a dbHelper class but it's the same problem...the solution seems to be to use the JNI_OnLoad to cache my class reference but JNI_OnLoad is never called, so I'm stuck!any help would be welcome.2011/3/26 fadden <fad...@android.com>
On Mar 22, 9:30 pm, earts <artyom.yego...@gmail.com> wrote:[...]
> On 23 мар, 04:54, fadden <fad...@android.com> wrote:
> //this code is executedThe invocation of JNI_OnLoad is done by System.loadLibrary(). If
> void android_main(android_app* state)
you're not using that to load the library, JNI_OnLoad won't happen.
If you're writing this as a native app, JNI_OnLoad isn't really
relevant.
@Philippe Simons:
i had same issues with FindClass from native thread.
Solution was:
1. Cache the instance of java.lang.ClassLoader (with
java.lang.Thread.currentThread().getContextClassLoader()), its jclass
and java.lang.ClassLoader.loadClass() in JNI_OnLoad;
2. Attach the native thread with AttachCurrentThread;
3. When you need to find new classes from native threads use
java.lang.ClassLoader.loadClass() (cast the result of loadClass() to
jclass);