开发者

JNI Warnig expected return type 'L' calling LocationManager.requestLocationUpdates

开发者 https://www.devze.com 2023-03-06 00:33 出处:网络
I am using Necessitas (QT in Android). Basically, using the Android NDK an android activity calls a QT application (.so).

I am using Necessitas (QT in Android). Basically, using the Android NDK an android activity calls a QT application (.so).

I am working on some bindings for the GPS. I think I am getting there, however I getting a JNI WARNING (JNI Warning expected return type 'L') when I call the method requestLocationUpdates(String, Long, Float, LocationListener).

Here is some of the code:

midGetSystemService = cu开发者_开发问答rrEnv->GetMethodID(actClass,"getSystemService","(Ljava/lang/String;)Ljava/lang/Object;");

jSystemServiceObj = currEnv->CallObjectMethod(currAct,midGetSystemService,StringArg);

midRequestLocationUpdates = currEnv->GetMethodID(locManClass,"requestLocationUpdates","(Ljava/lang/String;JFLandroid/location/LocationListener;)V");


midConstListener = currEnv->GetMethodID(listenerClass, "<init>", "()V");
jListenerObj = currEnv->NewObject(listenerClass, midConstListener);


currEnv->CallObjectMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj);  --->Here is the warning

Any idea why?


You are calling a method that returns "void":

midConstListener = currEnv->GetMethodID(listenerClass, "<init>", "()V");

using a JNI call that expects in return a JNI object:

// BAD
currEnv->CallObjectMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj);

You should instead use the JNI call that expects void in return:

// GOOD
currEnv->CallVoidMethod(jSystemServiceObj,midRequestLocationUpdates,StringArg,(jlong)1000,(jfloat)10,jListenerObj);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号