Search code examples
androidc++android-ndkorientationopenframeworks

How to call setRequestedOrientation() from cpp file?


I'm trying to limit available orientation in Android. It works well by setting the below flag on manifest file.

android:screenOrientation="portrait"

But I would like to set it by coding. I found this question from the link below.

Set the orientation to portrait from code

And it says I can set it with the following code.

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

But I'm using C++ based frameworks called openFrameworks for Android development and I have no idea how to call this method from ofApp.cpp file. Can someone please teach me how to do it? Thanks!


Solution

  • Here you can find the whole explanation Android Rotation Exploitation, the source code and the video. I hope this helps