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

I want to use "requestLocationUpdates" and set a listener callback. I got a error like "cannot find LocationListener class". pls give me some hint. here is my code:

    jstring gpsProviderStr = (jstring)(*env)->GetStaticObjectField(env, clazz, providerid);
        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 is an interface, therefore it has by definition no constructor. Only the class implementing this interface has an constructor you can call.

You can implement this interface in a self-written Java class and then create an instance of this self-written class. If you want you can implement the methods as native. This would allow you to handle the callback on location update in JNI.

Need Your Help

How to check if Google Street View Image API returns no image?

javascript google-street-view

I am using Google Street View image API to show an image of a location.

MongoDB - Mongoose: document structure/architecture

javascript node.js mongodb mongoose mongoose-populate

I have a relatively simple question, however, I keep getting stuck, over and over again. I think this is the fourth time I have tried to re-structure my documents to try and get the desired result....