简体   繁体   English

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

[英]How to call setRequestedOrientation() from cpp file?

I'm trying to limit available orientation in Android. 我试图限制Android中的可用方向。 It works well by setting the below flag on manifest file. 通过在清单文件上设置以下标志,它可以很好地工作。

android:screenOrientation="portrait" 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); 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. 但是我正在使用称为OpenFrameworks的基于C ++的框架进行Android开发,我不知道如何从ofApp.cpp文件中调用此方法。 Can someone please teach me how to do it? 有人可以教我该怎么做吗? Thanks! 谢谢!

Here you can find the whole explanation Android Rotation Exploitation , the source code and the video . 在这里,您可以找到有关Android Rotation Exploitation的完整说明, 源代码视频 I hope this helps 我希望这有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM