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

  1. If you have a single screen
  2. If you have only 2 screens in portrait and landscape mode
  3. If you have multiple screens in portrait orientation.

When auto-rotation is on, sometimes the flip will only occur upon the first launch of the app, but i cannot guarantee.

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.

27 Likes

Awesome work :ok_hand:

5 Likes

Good work man…

4 Likes

Welcome to extension development, David :tada:

5 Likes

Many Many Thanks For :free: This Extension

4 Likes

Geat Extension.Thank you so much.
I will test it

1 Like

My app is in full potrait mode. Will it work when i switch app in landscape mode on video full screen?

1 Like

Should work. Test it and let me know.

My app is in full potrait mode 100% working but one bug found fix this bug

3 Likes

That’s when auto rotation is set to on
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.

What did you mean by auto rotation on or off?
image
& Which one should i select?

Oh device autorotation!!
You should fix it (like sumit or deephost extension) .otherwise it will be an incompleted extension

1 Like

I’ve already found the solution with auto rotation on for portrait but still testing to make the extension do it automatically.

P.s other orientation fix extensions also have this problem.

3 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.

3 Likes

Nice work David and many many thanks for it.

3 Likes

Yes please provide this issue fix

1 Like

its not that big deal. most users have it off anyway. but if you still want to ignore it than do this.

how can i do it without editing through apk editor studio but with extension

You will still need to edit since the extension can only add duplicate screen values. so its best to edit and sign with your keys.

Thanks for uploading free this extatension

1 Like

Thank you very much. Since the bug appeared, I’ve been trying to find a solution and nothing. This extension works great. Thanks!