Android: Using JNI from NativeActivity

后端 未结 2 1438
不思量自难忘°
不思量自难忘° 2021-02-15 11:35

We are developing an OpenGL game on android using the NativeActivity class. So far everything went OK, but now we need to access some functionality that only seems to be availab

2条回答
  •  旧巷少年郎
    2021-02-15 12:01

    Ech, I've been staring at the code for couple of hours and didn't see it. Then left the desk, came back and there it was:

    Instead of these two lines

    float xdpi = jni->GetFloatField(displayMetricsClass, xdpi_id);
    int height = jni->GetIntField(displayMetricsClass, height_id);
    

    I should have used:

    float xdpi = jni->GetFloatField(displayMetrics, xdpi_id);
    int height = jni->GetIntField(displayMetrics, height_id);
    

    Doh :)

    (at least it can serve as an example if someone wants to get DPI the hard way :) )

提交回复
热议问题