android - JNI: HOWTO FIND 'public interface LocationListener {}' by C -


i want use "requestlocationupdates" , set listener callback. got error "cannot find locationlistener class". pls give me hint. here code:

    jstring gpsproviderstr = (jstring)(*env)->getstaticobjectfield(env, clazz, providerid); //error:         jclass listenerclass = (*env)->findclass(env,"android/location/locationlistener"); //cannot find class          jmethodid mlistener = (*env)->getmethodid(env, listenerclass, "<init>", "()v");         jobject listenerobj = (*env)->newobject(env, listenerclass, mlistener);         jmethodid mreqlocupdates = (*env)->getmethodid(env, clazz, "requestlocationupdates","(ljava/lang/string;lflandroid/location/locationlistener;)v"); //callback? right?         (*env)->callvoidmethod(env, locmgrobj, mreqlocupdates, gpsproviderstr, interval, 0, listenerobj); //set callback 

locationlistener interface, therefore has definition no constructor. class implementing interface has constructor can call.

you can implement interface in self-written java class , create instance of self-written class. if want can implement methods native. allow handle callback on location update in jni.


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -