kivy / kivy/python-for-android

Fix screen orientation of PythonActivity.java

Open
#3,004 1 comment 0 reactions 0 assignees View on GitHub
bug need-analysis Priority: Low
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)):

![image](https://github.com/kivy/python-for-android/assets/61960169/b2872545-7838-416a-b174-1155bcea51a6)

![image](https://github.com/kivy/python-for-android/assets/61960169/38f5503c-58bd-468a-88ed-b0ffe4c2e0c1)

Then everything works ok..

Spec file:
```
orientation = portrait
android.manifest.orientation = fullUser
```

Contributor guide

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.