8000 Setting `android:screenOrientation` via `--orientation` has no effect when targeting API 31 · Issue #2724 · kivy/python-for-android · GitHub
[go: up one dir, main page]

Skip to content
Setting android:screenOrientation via --orientation has no effect when targeting API 31 #2724
Closed
@misl6

Description

@misl6

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: Any
  • OS: Any
  • Kivy: Any
  • Cython: Any
  • OpenJDK: Any

Description

python-for-android made possible to set the activity android:screenOrientation via --orientation argument.
Unfortunately, when targeting API 31 and above, on Android 12 and above, this attribute is ignored, as the activity will run in multi-window mode.

From Android Docs:

android:screenOrientation
The orientation of the activity's display on the device. The system ignores this attribute if the activity is running in multi-window mode.

On Android 12, the multi-window mode is the standard behavior, and additionally:

On large screens (sw >= 600dp), the platform supports all apps in multi-window mode regardless of app configuration. If resizeableActivity="false", the app is put into compatibility mode when necessary to accommodate display dimensions.

On small screens (sw < 600dp), the system checks an activity’s minWidth and minHeight to determine whether the activity can run in multi-window mode. If resizeableActivity="false", the app is prevented from running in multi‑window mode regardless of minimum width and height.

So, resizeableActivity="false"might be great to handle some specific configurations, but is not meant to be a solution for that.
Also, users may want to take advantage of such a feature. (Since the vastly majority of Apps now support multi-window m 5B05 ode)

But we still want to force a specific orientation, when the app is not in multi-window mode:

Setting KIVY_ORIENTATION to a supported SDL configuration, (Portrait, LandscapeRight, ...) will force the App to keep the selected orientation, even if the device gets rotated.

So, as a quick workaround:

import os

os.environ["KIVY_ORIENTATION"] = "Portrait"

In a near future:
We should advise users that --orientation has no effect anymore, and we should think about a (cross-platform?) migration plan.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0