kivy/python-for-android

Fix screen orientation of PythonActivity.java

BlackCatDevel0per opened this issue · 0 comments

Checklist

  • 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
  • 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 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:

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):

image

image

Then everything works ok..

Spec file:

orientation = portrait
android.manifest.orientation = fullUser