How do I set the build for Landscape mode only?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I set the build for Landscape mode only?

Dave McLaughlin
I want to set the build so that the only screen orientation available is landscape.

I have disabled autorotation but one app I run always changes the display to portrait and this is not ideal on a landscape only display. It changes back to landscape on exit but is not very user friendly from the 90 deg angle. 

Where in the build can I make changes that prevent any orientation changes by any app?

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/95bac013-4082-456b-aaa7-4ecd4b27b509o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I set the build for Landscape mode only?

Budhdi Sharma

To get an Android application to display in landscape mode only (to lock it in landscape mode), add this line to your Activity definition in the AndroidManifest.xml file:

android:screenOrientation="landscape"

For example, I’m writing an Android football game right now, and this is the definition for my main activity in the Android manifest file:

<activity
    android:name=".MainActivity"
    android:screenOrientation="landscape"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

On Wednesday, June 17, 2020 at 7:59:39 PM UTC+5:30, Dave McLaughlin wrote:
I want to set the build so that the only screen orientation available is landscape.

I have disabled autorotation but one app I run always changes the display to portrait and this is not ideal on a landscape only display. It changes back to landscape on exit but is not very user friendly from the 90 deg angle. 

Where in the build can I make changes that prevent any orientation changes by any app?

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/83cee293-d0ff-4a19-b4c7-702edc776cfbo%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I set the build for Landscape mode only?

Dave McLaughlin
In reply to this post by Dave McLaughlin
Yeah, that works for each application but I was referring to the platform build itself not offering a portrait orientation as an option, similar to what it does when running on HDMI displays. 

I was given a solution that works but sadly, the running app is given a simulated portrait view within the landscape orientation which doesn't reset back to full landscape when that app exists but I have added this to my main app so that takes care of the issue and doesn't give me a rotate 90 deg portait view/ Not ideal but it works.


On Wednesday, 17 June 2020 21:29:39 UTC+7, Dave McLaughlin wrote:
I want to set the build so that the only screen orientation available is landscape.

I have disabled autorotation but one app I run always changes the display to portrait and this is not ideal on a landscape only display. It changes back to landscape on exit but is not very user friendly from the 90 deg angle. 

Where in the build can I make changes that prevent any orientation changes by any app?

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/8ad7b310-1017-4986-b7df-bd9eea7101a3o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I set the build for Landscape mode only?

Trần Kha
Hi Dave,

Please refer below steps to force orientation to landscape:

1. Make sure only landscape permission is available on your build environment

Only add android.hardware.screen.landscape.xml to your makefile by below command:

PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.screen.landscape.xml:system/etc/permissions/android.hardware.screen.landscape.xml \

Remove android.hardware.screen.portrait.xml if it exists

2. Add an overlay to force landscape mode
Assume you have device/company/device_x

Create a config.xml file and put it in

device/company/device_x/overlay/framework/base/res/res/values

Contents of config.xml:

<resources>
      <bool name="config_forceDefaultOrientation">true</bool>
</resources>

3. Make sure your overlay in config.xml is used

PRODUCT_PACKAGE_OVERLAYS += device/company/device_x/overlay

Done! Your system is always landscape!

Note: This solution only works on Android P or older Android version. From Android Q, Google changes to use new solution.

Limitation: The app which sets portrait as orientation in AndroidManifest.xml can’t display properly! Ex: Antutu Benmark.

By the way, I had found solution for above limitation by creating a broadcast service which tried to convert rotation of the application. But i just forgot the reference. I will try to find it and share you later!

Best Regards,
KHA Tran




--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/0c74c118-fa37-43cb-bfeb-fc3fd15dd2a3o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I set the build for Landscape mode only?

Dave McLaughlin
I have Android 7.1 and I implemented all of the changes you indicated, although you do indicate P or higher I thought I would try it. During the boot, the boot logo was still in portrait mode due to the fact that the default orientation of the LCD display is portrait mode (the timings are for 800x1280 and not 1280x800)

When I flash the new OS to the board and then boot it and Android finally starts, the display is initially in landscape mode but quickly changes to portrait. Subsequent reboots are straight into portrait. I've not been able to track down which part of the source is selecting portrait.

By the way, the exact same build running on the same processor board but with an 800x480 LCD that is default landscape timing, comes up as landscape. 

On Wednesday, 8 July 2020 at 01:28:37 UTC+7 [hidden email] wrote:
Hi Dave,

Please refer below steps to force orientation to landscape:

1. Make sure only landscape permission is available on your build environment

Only add android.hardware.screen.landscape.xml to your makefile by below command:

PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.screen.landscape.xml:system/etc/permissions/android.hardware.screen.landscape.xml \

Remove android.hardware.screen.portrait.xml if it exists

2. Add an overlay to force landscape mode
Assume you have device/company/device_x

Create a config.xml file and put it in

device/company/device_x/overlay/framework/base/res/res/values

Contents of config.xml:

<resources>
<bool name="config_forceDefaultOrientation">true</bool>
</resources>

3. Make sure your overlay in config.xml is used

PRODUCT_PACKAGE_OVERLAYS += device/company/device_x/overlay

Done! Your system is always landscape!

Note: This solution only works on Android P or older Android version. From Android Q, Google changes to use new solution.

Limitation: The app which sets portrait as orientation in AndroidManifest.xml can’t display properly! Ex: Antutu Benmark.

By the way, I had found solution for above limitation by creating a broadcast service which tried to convert rotation of the application. But i just forgot the reference. I will try to find it and share you later!

Best Regards,
KHA Tran




--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/150fb306-42d2-45c2-9c67-f75d1961186en%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: How do I set the build for Landscape mode only?

rashad roberson
Thank so much for the I was trying to upgrade and had not been able succeeded 

On Wed, Sep 2, 2020, 7:42 AM Dave McLaughlin <[hidden email]> wrote:
I have Android 7.1 and I implemented all of the changes you indicated, although you do indicate P or higher I thought I would try it. During the boot, the boot logo was still in portrait mode due to the fact that the default orientation of the LCD display is portrait mode (the timings are for 800x1280 and not 1280x800)

When I flash the new OS to the board and then boot it and Android finally starts, the display is initially in landscape mode but quickly changes to portrait. Subsequent reboots are straight into portrait. I've not been able to track down which part of the source is selecting portrait.

By the way, the exact same build running on the same processor board but with an 800x480 LCD that is default landscape timing, comes up as landscape. 

On Wednesday, 8 July 2020 at 01:28:37 UTC+7 [hidden email] wrote:
Hi Dave,

Please refer below steps to force orientation to landscape:

1. Make sure only landscape permission is available on your build environment

Only add android.hardware.screen.landscape.xml to your makefile by below command:

PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.screen.landscape.xml:system/etc/permissions/android.hardware.screen.landscape.xml \

Remove android.hardware.screen.portrait.xml if it exists

2. Add an overlay to force landscape mode
Assume you have device/company/device_x

Create a config.xml file and put it in

device/company/device_x/overlay/framework/base/res/res/values

Contents of config.xml:

<resources>
<bool name="config_forceDefaultOrientation">true</bool>
</resources>

3. Make sure your overlay in config.xml is used

PRODUCT_PACKAGE_OVERLAYS += device/company/device_x/overlay

Done! Your system is always landscape!

Note: This solution only works on Android P or older Android version. From Android Q, Google changes to use new solution.

Limitation: The app which sets portrait as orientation in AndroidManifest.xml can’t display properly! Ex: Antutu Benmark.

By the way, I had found solution for above limitation by creating a broadcast service which tried to convert rotation of the application. But i just forgot the reference. I will try to find it and share you later!

Best Regards,
KHA Tran




--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/150fb306-42d2-45c2-9c67-f75d1961186en%40googlegroups.com.

--
--
unsubscribe: [hidden email]
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/CAL1SjPiSradqbZC66vndk6k8VuYr%2BFfvujAWsC0t-L26Av%3DSHQ%40mail.gmail.com.