i want to get screen size via c. i know that jni support calling java from c. but is there any person who knows another method? i mean get screen size from lowlevel modules
For anyone like me who is looking for a pure C++ way of doing this, reading /dev/graphics/fb0
does not work reliably. On many devices, it returns an incorrect result (on mine it returns 640 X 400).
This is a problem for situations in which you cannot use ANativeWindow
or ANativeWindow_Buffer
, for example in a native binary executable.
What worked for me :
Assuming you have a rooted phone, you can process the output of the below command to read the resolution reliably.
su -c dumpsys display | grep mBaseDisplayInfo