kivy / kivy/python-for-android
Fix screen orientation of PythonActivity.java
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 2k
- Avg merge
- 12h 20m
- Merged PRs (30d)
- 9
Description
### Checklist
- [X] the issue is indeed a bug and not a support request
- [ ] issue doesn't already exist: https://github.com/kivy/python-for-android/issues
- [ ] I have a short, runnable example that reproduces the issue
- [X] I reproduced the problem with the latest development version (`p4a.branch = develop`)
- [ ] I used the grave accent (aka backticks) to format code or logs when appropriated
### Versions
- Python: 3.10
- OS: Android
- Kivy: 2.3.0
- Cython: 0.29.37
- OpenJDK: 17
### Description
Hi, could you please modify [PythonActivity.java](https://github.com/kivy/python-for-android/blob/develop/pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java#L140-L146) to either add additional options or to gracefully handle cases where the `android.manifest.orientation` parameter is already specified in the manifest? This adjustment would prevent conflicts and ensure smoother integration with buildozer.spec configurations.
Currently, users need to set it inside the app using `mActivity.setRequestedOrientation`. For example: `mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER)`, full minimal code:
```python
from android import mActivity
from jnius import autoclass
ActivityInfo = autoclass('android.content.pm.ActivityInfo')
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER)
```
Screenshot from app's ipykernel (part of my sample in [git repository](https://github.com/BlackCatDevel0per/p4adev_toolkit)):


Then everything works ok..
Spec file:
```
orientation = portrait
android.manifest.orientation = fullUser
```
Contributor guide
Research direction
Start with pythonforandroid/bootstraps/sdl2/build/src/main/java/org/kivy/android/PythonActivity.java around lines 140-146, then compare the orientation and android.manifest.orientation settings shown in the buildozer.spec example. Check how the manifest value and runtime setRequestedOrientation call interact; done means the specified orientation is handled without a conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, python
- Domain
- build-system, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100