1 编写JniInterface.java文件,定义所需的native 接口。如:
public class JniInterface{
private static String TAG= "jniinterface_hdmi";
public static int check_hdmi(){
Log. i(TAG, "check_hdmi");
return checkHdmi();
}
public static int get_max_res() {
Log. i(TAG, "get_max_res");
return getMaxRes();
}
static{
System. loadLibrary("jni_hdmi_monitor");
}
native static int checkHdmi();
native static int getMaxRes();
}
2 编译生成class文件,见bin\classes目录。 对应一个包目录。如:com\ipanel\home\launcher\JniInterface.class
3 打开cmd到bin\classes目录,执行:E:\workspace\eclipse_test\iPanel_HuNanHomeLauncher\bin\classes>javah -jni com.ipanel.home.launcher.JniInterface
即可生成 jni头文件。
4 在c文件实现对应的native接口即可。