[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: GitHub - DavidNingthou/Orientation-Fix: This extension of app inventor fixes orientation problem in app inventor and it's distors.

11 Likes

Many Many Thanks For :free: This Extension

1 Like

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)

I have noticed it lately. It was working on my tests. idk.

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.

1 Like

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

@David_Ningthoujam, if you could provide me the extension I would test it and see how it works in my apps that are based on portrait orientation.

Thank you in advance!

protip: as always you can find the extension in the first post of an extension thread
Taifun

1 Like

I know that.

What I have understood in his response to me is that he is offering me another version of the extension. That's why I asked for it.

If I've understood it wrong, I'm sorry and my post can be deleted.

1 Like

You would still need to edit the manifest and delete original screen values, and the extension is hard coded on screen names like screen1,2,3 etc.

It's best to just put the line of code for every screen your app has.

There are many guides for editing manifest on the community if you would need some help.

1 Like