如何从 cpp 文件中调用 setRequestedOrientation()?

How to call setRequestedOrientation() from cpp file?

我正在尝试限制 Android 中的可用方向。 通过在清单文件中设置以下标志,效果很好。

android:screenOrientation="portrait"

但是我想通过编码来设置它。 我从下面的 link 中找到了这个问题。

Set the orientation to portrait from code

它说我可以用下面的代码设置它。

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

但是我正在使用名为 openFrameworks 的基于 C++ 的框架进行 Android 开发,我不知道如何从 ofApp.cpp 文件中调用此方法。 有人可以教我怎么做吗? 谢谢!

在这里你可以找到完整的解释Android Rotation Exploitation, the source code and the video。希望对您有所帮助