我正在为 JNI 使用一些示例代码。
我有一个 Java 类,
public String getArtists(Context context)
...
但是,如下所示的 C++ 接口(interface)只返回一个空指针
s_getArtistsGetArtistsMethodID = env->GetMethodID(s_getArtistsClassID, "getArtists", "(Landroid/content/Context;)V");
我在这里错过了什么?下面的代码按预期工作,所以我认为它与上下文参数有关。
s_getArtistsConstructorMethodID = env->GetMethodID(s_getArtistsClassID, "<init>", "()V");
非常感谢您的帮助!
最佳答案
返回值错误。 V 是void,你返回一个字符串。尝试:
env->GetMethodID(s_getArtistsClassID, "getArtists", "(Landroid/content/Context;)Ljava/lang/String;"
关于java - JNI 获取上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18301780/