Force portrait mode

Here you can talk about anything related to BBC BASIC, not covered in another category
Ric
Posts: 223
Joined: Tue 17 Apr 2018, 21:03

Force portrait mode

Post by Ric »

Evening all,
does anyone know how to force a media device (android phone) to stay in portrait mode even if auto rotate is enabled in settings?
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 458
Joined: Tue 18 Jun 2024, 09:32

Re: Force portrait mode

Post by Richard Russell »

Ric wrote: Sat 12 Jul 2025, 19:30 does anyone know how to force a media device (android phone) to stay in portrait mode even if auto rotate is enabled in settings?
Assuming you're using BBC2APK to build your app, I believe it tells you how to do that in the Help text.

However I haven't tried it in a long time, and since Android is always changing things my confidence that it will still work is limited! ;)
Ric
Posts: 223
Joined: Tue 17 Apr 2018, 21:03

Re: Force portrait mode

Post by Ric »

Thanks Richard, I haven't tried to build the app yet, but I'll look through the help text to see
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 458
Joined: Tue 18 Jun 2024, 09:32

Re: Force portrait mode

Post by Richard Russell »

Ric wrote: Sun 13 Jul 2025, 08:22 Thanks Richard, I haven't tried to build the app yet, but I'll look through the help text to see
There's no way to force a particular orientation without building your own APK because that (and many other things, such as what permissions are requested) is a function of the app's manifest and that's something built into the APK.

You might be able to install an ON MOVE handler which emits some JNI code to flip the orientation back to what you want, but that would involve a disturbance to the screen because the orientation will change and then change back!

If the disturbance is acceptable, and you want to try that approach, there's a Stack Overflow article here. Calling the JNI from BBC BASIC code is not straightforward, but I have done it in the past.

On the general issue of forcing a particular orientation I asked DeepSeek and it said that Android is making this increasingly difficult, if not impossible, because it's contrary to the philosophy of Android apps being able to adapt to any screen size or shape.

Perhaps you should reconsider your approach in light of this.