Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
TheMarco
Posts: 669
Registered: ‎02-19-2011
My Device: BlackBerry PlayBook 32GB
My Carrier: Sprint

BB10 webworks force orientation change and then lock

Is it already possible to programmatically force an orientation (landscape in my case) and temporarily lock the device to this orientation? I desperately need this for my app.

Staff UI Prototyper (read: full-time hacker)


My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App

Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 webworks force orientation change and then lock


TheMarco wrote:

Is it already possible to programmatically force an orientation (landscape in my case) and temporarily lock the device to this orientation? I desperately need this for my app.


From what I know there is a bug and the orientation from a config.xml file isn't really considered at this time. If this got fixed in the next update of either WebWorks or the Dev Alpha OS it should work by adding this line to your config.xml file:

 

<!-- The rim:orientation element specifies the orientation for screens in BlackBerry WebWorks application. -->
<rim:orientation mode="landscape" />

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.
Administrator
astanley
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 webworks force orientation change and then lock

Marco, no we don't yet have a programmatic way of doing this at runtime.  You can currently lock orientation to portrait or landscape at compile time.

 

I suspect a custom extension may allow you to change the properties of the WebView object container, but this hasn't been proven whether it would force orientation after the object has already been staged.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Please use plain text.
New Contributor
hoomi_2010
Posts: 4
Registered: ‎08-20-2012
My Device: Alpha Device
My Carrier: 3

Re: BB10 webworks force orientation change and then lock

I have done it using a custom extension for the WebWroks (as astanley correctly mentioned). The native api that you will need to call is navigator_set_orientation_mode(NAVIGATOR_LANDSCAPE, NULL))
remember you need to call bps_initialize() && and bps_shutdown()
I hope that it helps.(It was a pain for me to figure this out :smileywink:)
Please use plain text.
BlackBerry Development Advisor
Nukul
Posts: 115
Registered: ‎06-06-2011
My Device: 9800
My Carrier: Rogers

Re: BB10 webworks force orientation change and then lock

It will be supported in the next version through the config.xml
We are very close to the next release so I wild just hold on writing a native extension for this.
@nukulb
Please use plain text.
BlackBerry Development Advisor
cdelcol
Posts: 37
Registered: ‎01-08-2010
My Device: Various
My Carrier: Rogers

Re: BB10 webworks force orientation change and then lock

Just to clarify. Specify orientation of the app via config.xml will be available at our next release:

https://github.com/blackberry/BB10-WebWorks-Framework/issues/88

 

The ability to change orientation lock via an api at execution is defined, but is not yet done:

https://github.com/blackberry/BB10-WebWorks-Framework/issues/243

 

Please be aware that the way to set initial orientation is a little different in order to align better with the W3c:

 

<feature id="blackberry.app.orientation">

  <param name="mode" value="portrait" />
</feature>

 

This feature will only be available at the root of the config.xml, not nested below access elements, and applies to the entire application.

 

 

Please use plain text.