[F/OS] Screen Orientation Fix

There is a bug in the App Inventor framework that causes a screen orientation flip issue. The “orientation” option for screen orientation does not behave as expected, resulting in unintended behavior. This extension solves the problem by using reflection to access the ScreenOrientation.class, which is part of the App Inventor framework. It modifies its internal state to replace the “unspecified” screen orientation value with “User” for all screens, thus correcting the issue.

This extension is similar to one made by Sumit and does not have any blocks. To use it, simply drag it to Screen1 and it will work automatically.

The extension has some working conditions, however. When auto-rotation is off, it will work for the following conditions:

If you have a single screen
If you have only 2 screens in portrait and landscape mode
If you have multiple screens in portrait orientation.
When auto-rotation is on, the flip will only occur upon the first launch of the app, but switching screens should work fine afterward.

Please note that this is my first extension, and I am still in the learning phase. Feel free to experiment with the code and make any necessary changes. Thank you for your understanding.

Aix download:
com.DavidNingthoujam.ScreenOrientationFix.aix (9.5 KB)

Source Code on GitHub:

9 Likes

Many Many Thanks For :free: This Extension

1 Like

Congratulations for this, man :clap: :clap:
Double congratulations for making it open source.
As it is open source, I hope Niotron and others builders incorpore your code in the builders.

2 Likes

Thank you very much for your contribution! :slightly_smiling_face:

I’ve tested the extension and it really does fix the problem if auto-rotation is off.

However, if the auto-rotation is on, the feature didn’t work as described - unfortunately the flip occurs when switching screens.

(Tested on Android 10, 11 and 12)

Fix this bug Android 13

The extension currently does not seem to work properly when auto rotation is on. There is no solution yet. Also, most users have it off anyway.

Remember, this is just a temporary solution because of the limitations on extensions. Devs should fix it internally in order to completely fix the issue.

2 Likes

I agree. Extensions can only be a “band-aid” solution to a problem and at most be a workaround. Deep down, this does not solve the problem itself. It is up to the developers to actually “cure the wound” and fix the problem.

3 Likes

thank you for this extension. I have noticed this problem and I hope this comes handy in my app updates, thank you once again

2 Likes

To ignore auto rotation for Portrait apps. Add this to the menifest for every screen.

android:screenOrientation=“portrait”

I tried making the extension add it, it adds but as a duplicate. Seems like we can’t replace the original screen values. If you still want the extension to add and just delete the original screen manifest data than i can provide you the extension.

1 Like