jni invalid jobject
【摘要】 use of invalid jobject
原因:
CallVoidMethod
传参数多传了一个对象
int helmControlStatusNotify(const PVSDK_HELMCONTROLSTATUS_PARAM info)
{
LogFactory *factory = Log...
原因: CallVoidMethod 传参数多传了一个对象
int helmControlStatusNotify(const PVSDK_HELMCONTROLSTATUS_PARAM info)
{
LogFactory *factory = LogFactory::getInstance();
PvLog *consoleLog = factory->create(PV_LOG_TYPE_CONSOLE, PV_LOG_LEVEL_DEBUG, NULL);
int needsDetach;
JNIEnv* sdkenv=getJNIEnv(&needsDetach);
jclass globalcallBackcls=sdkenv->GetObjectClass(globalcallBack);
jmethodID jmid=sdkenv->GetMethodID(globalcallBackcls,"helmControlCallback","(Lcom/shares/sdk/callinfo/HelmControlStatus;)V");
if(jmid==NULL) {
consoleLog->writeLog(PV_LOG_LEVEL_ERROR, "----helmControlCallback is null ----\n");
}
jclass objectClass=sdkenv->GetObjectClass(helmControlStatusobj);
jfieldID mode = sdkenv->GetFieldID(objectClass, "mode", "B");
jfieldID expect = sdkenv->GetFieldID(objectClass, "expect", "B");
sdkenv->SetByteField(helmControlStatusobj, mode,info.mode);
sdkenv->SetByteField(helmControlStatusobj, expect,info.expect);
consoleLog->writeLog(PV_LOG_LEVEL_ERROR, "----helmControlCallback 5 ----\n");
//错误的: sdkenv->CallVoidMethod(globalcallBack, jmid, info , helmControlStatusobj);
sdkenv->CallVoidMethod(globalcallBack, jmid,helmControlStatusobj);//ok
// sdkenv->DeleteLocalRef(objectClass);
sdkenv->DeleteLocalRef(globalcallBackcls);
return 1;
}
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/61419679
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)