0

我想通过 C 获取屏幕大小。我知道我们可以使用 JNI 从 c 调用 Java。但是有什么办法可以直接通过C?我的意思是从低级模块获取屏幕大小而不调用 Java,而只调用 C。我在下面使用了这些代码(通过 C 复制表单 android 获取屏幕大小),但不起作用,它返回宽度:10925409 和高度:0:

// ... Other standard includes ...
#include <sys/ioctl.h>
#include <linux/fb.h>

//...

struct fb_var_screeninfo fb_var;
int fd = open("/dev/graphics/fb0", O_RDONLY);
ioctl(fd, FBIOGET_VSCREENINFO, &fb_var);
close(fd);
// screen size will be in fb_var.xres and fb_var.yres   
4

0 回答 0