简体   繁体   中英

Android NDK : How to get screen resolution in native binary?

I have a native binary for armeabi-v7a running on an Android phone that needs to get the current resolution of the screen.

I've tried reading the framebuffer resolution from /dev/graphics/fb0 but it gives me an incorrect value (640 X 400).

Most of the solutions discussed online involve using Java , ANativeWindow or ANativeWindow_Buffer , none of which are applicable to my scenario.

Is there a way to do this?

For anyone who stumbles across this, I eventually ended up processing the output of the below command.

su -c dumpsys display | grep mBaseDisplayInfo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM