Tv Box Screen Rotation is complex, let’s say the true. Sometimes we need our APP running on portrait mode, as if we are on Digital Signage business. From Exodux Box, we want to share a method to rotate the screen:
Mainly we get get the runtime and read ‘persist.sys.app.rotation’ property (we get ‘middle-port’ by default):
Or, by same way, we can set the ‘persist.sys.app.rotation’ property to ‘original’ or other:
Then we can rotate the screen by using these methods:
A) setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
By default, the value is ‘middle-port’, but we can change to ‘original’ by getting the runtime. If we use ‘original’ value the behabiour will be as a mobile phone or tablet and your app will not be locked to landscape.
Button ‘Swap Rotation Mode’ switches between ‘original’ and ‘middle-port’, the current value will be displayed.
Buttom ‘Set Portrait Mode’ will swap the screen orientation to portrait.
Button ‘Set Landscape Mode’ will swap the screen orientation to landscape.
If we want a properly portrait usage, first change mode to ‘original’, then set to portrait.
We try to make it easy, so, already precompiled a demo application and opened the source. There are probably many ways and as each developer may be building a total different app we are not sure if this is the best solution for you, but anyway, it may be an interesting option.
Both, compiled APK and open source code are available here: ROTATE EXODUX BOX SCREEN
Here at Exodux we can also set your OEM firmware to “original” mode from factory, please, contact us anytime.