buildozer
buildozer copied to clipboard
Changing the screen orientation depending on the auto-rotate setting
Description
Hello. At the moment, based on the documentation, Buildozer supports portrait and landscape orientations, but the application changes the screen orientation regardless of the state of the sensor on the user’s device. Thus, the orientation changes even if auto-rotation of the screen is disabled in the device settings. I've seen examples of fixing this using pyjnius but I would like to know if Buildozer supports this?
Buildozer app rotation is enabled in buildozer.spec using orientation options. https://github.com/Android-for-Python/Android-for-Python-Users#orientation
Android has a global 'auto-rotate' enable/disable option as part of Accessibility options.
Yes, I can confirm that Buildozer builds apps that ignore Android's global 'auto-rotate' disable.
In fact, I expect Buildozer apps ignore all the Android Accessibility options.
Hi @bl1nch,
Can you please post your buildozer.spec file and confirm that the build has been performed with the latest version of buildozer from scratch?
Hi @misl6, sorry for such a late reply
If it suddenly matters I have a custom build method with Github Actions, so I clone p4a and make some changes every time, so don't mind this line:
p4a.source_dir = .python/python-for-android
I constantly use the latest version of the builldozer
The solution with pyjnius that I found on the internet, but I’m not sure if it works since I haven’t had time to check it yet:
from jnius import autoclass
PythonActivity = autoclass("org.kivy.android.PythonActivity")
ActivityInfo = autoclass("android.content.pm.ActivityInfo")
activity = PythonActivity.mActivity
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER)
Hi @misl6, sorry for such a late reply
If it suddenly matters I have a custom build method with Github Actions, so I clone p4a and make some changes every time, so don't mind this line:
p4a.source_dir = .python/python-for-androidI constantly use the latest version of the builldozer
The solution with pyjnius that I found on the internet, but I’m not sure if it works since I haven’t had time to check it yet:
from jnius import autoclass PythonActivity = autoclass("org.kivy.android.PythonActivity") ActivityInfo = autoclass("android.content.pm.ActivityInfo") activity = PythonActivity.mActivity activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER)
I recently tested this solution and it works perfect
have a custom build method with Github Actions
Which version of buildozer uses?
Last build with version 1.5.0
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have the means to take action. Please reach out if you have or find the answers we need so that we can investigate further.