Hi, I'm trying to adapt my pdf reader to the PRS T1. Since it is in C++ (Qt) I'd like to set the update mode using JNI. Do you think code like this (based on hberntsen's apk) could work, or do you see any fundamental flaw/possible improvements?
Edit:Turns out that it didn't work. Some useful subclass of Context (like Activity) is needed, however a plain Activity fails too (throws a NullPointerExeption, when I try to create the Listview with it). Is it possible to create Activities in JNI without subclassing them?
Code:
#include <jni.h>
extern JavaVM* jvm;
void setUpdateMode(int mode){
JNIEnv *jenv;
jvm->AttachCurrentThread(&jenv, NULL);
//Context is too abstract, some kind of Activity needed
jclass ctext_cls = jenv->FindClass("android/content/Context");
jmethodID ctext_ctr = jenv->GetMethodID(ctext_cls,"<init>", "()V");
jobject ctext = jenv->NewObject(ctext_cls, ctext_ctr);
jclass lview_cls = jenv->FindClass("android/widget/ListView");
jmethodID lview_ctr = jenv->GetMethodID(lview_cls,"<init>", "(Landroid/content/Context;)V");
jmethodID invMethod = jenv->GetMethodID(lview_cls, "invalidate","(I)V");
jobject lview = jenv->NewObject(lview_cls, lview_ctr, ctext);
jenv->CallVoidMethod(lview,invMethod,mode);
}