jni文件传递方法参数

使用jni从java传递多个参数到c++时,如果是多个参数,当是string类型时,参数之间用;分割
	void sendToAndoridAdmobId(const char* id)
	{
		JniMethodInfo methodInfo;

														 
		if (!JniHelper::getStaticMethodInfo(methodInfo, JavaTool_ClassName, "setDomobUnitId", "(Ljava/lang/String;)V"))
		{
			return;
		}
		jstring l_stringUrl = methodInfo.env->NewStringUTF(id);
		methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, l_stringUrl);
		methodInfo.env->DeleteLocalRef(methodInfo.classID);		
		
	}


对应的java代码

	 public static void  setDomobUnitId(String id)
	 {
		 JavaTool.DOMOB_UNIT_ID = id;
	 }


但是如果是int类型,就直接挨在一起写了
	void sendToAndoridWidthHeight(int width ,int height)
	{
		JniMethodInfo methodInfo;


		if (! JniHelper::getStaticMethodInfo(methodInfo, JavaTool_ClassName, "sendToAndroidWidthHeight", "(II)V"))
		{			
			return;
		}

		
		methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, width,height);
		methodInfo.env->DeleteLocalRef(methodInfo.classID);
	}	

对应的java代码

	 public static void  sendToAndroidWidthHeight(int width , int height)
	 {
		 JavaTool.width = width;
		 JavaTool.height = height;
	 }



可以用javap   -s   -p   yourclassname 这个命令得到内部类型签名

你可能感兴趣的:(jni)