android get screen size via C

后端 未结 6 1493

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

6条回答
  •  盖世英雄少女心
    2020-12-11 05:13

    You don't need the buffer but you could use the ANativeWindow class if you pass in a Surface from java.

    void Java_com_justinbuser_nativecore_NativeMethods_setSurface(JNIEnv * env, jobject this, jobject surface){
            ANativeWindow nativeWindow = ANativeWindow_fromSurface(env, surface);
        int width =  ANativeWindow_getWidth(renderEngine->nativeWindow);
        int height = ANativeWindow_getHeight(renderEngine->nativeWindow);
    }
    

提交回复
热议问题