<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; orientation</title>
	<atom:link href="http://devblog.blackberry.com/tag/orientation/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Wed, 22 May 2013 17:24:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; orientation</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Sensors on BlackBerry 10 Have Arrived!</title>
		<link>http://devblog.blackberry.com/2012/10/sensors-on-blackberry-10-have-arrived/</link>
		<comments>http://devblog.blackberry.com/2012/10/sensors-on-blackberry-10-have-arrived/#comments</comments>
		<pubDate>Fri, 12 Oct 2012 15:10:32 +0000</pubDate>
		<dc:creator>Shadid</dc:creator>
				<category><![CDATA[Cascades]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Acceleration]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[orientation]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=11629</guid>
		<description><![CDATA[Here&#8217;s a guest post from Adam Parco from our Sensor Algorithms &#38; Services team &#8211; Ed. Developing for BlackBerry® has never been faster or easier.  We have been working hard to give you the same experience when incorporating sensors into your game or application.  With the release of Beta 3, we have added complete support for [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11629&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em>Here&#8217;s a guest post from Adam Parco from our Sensor Algorithms &amp; Services team &#8211; Ed.</em></p>
<p><img class="aligncenter size-full wp-image-11631" title="embed" alt="TITLE_IMAGE" src="http://rimdevblog.files.wordpress.com/2012/10/embed.png?w=188&#038;h=288" height="288" width="188" /></p>
<p>Developing for BlackBerry® has never been faster or easier.  We have been working hard to give you the same experience when incorporating sensors into your game or application.  With the release of Beta 3, we have added complete support for sensors in Cascades™, leveraging the power of Qt Sensors from Qt Mobility.  QML gives you the unparalleled flexibility and simplicity of adding a sensor to your app in as little as 4 lines of code!</p>
<pre>   Compass {
      active: <b>true</b>
      onReadingChanged: {
          console.<b>log</b>("Azimuth" + <span style="text-decoration:underline;">reading.</span>azimuth);
      }
   }</pre>
<p>Of course we still also support the C++ Qt Sensor API for those hardcore developers out there.  For more information on including and using sensors in your project check out the newly updated documentation <a href="https://developer.blackberry.com/cascades/documentation/device_comm/sensors/index.html" target="_blank">here</a>.</p>
<p>The device movement alarm is a great example on leveraging some of RIM®&#8217;s exclusive API extensions.  Use them to differentiate your app.  Look for the following APIs:</p>
<ul>
<li>axesOrientationMode</li>
<li>accelerationMode</li>
<li>alwaysOn</li>
<li>skipDuplicates</li>
</ul>
<p>By now you are probably screaming “Show me the code!”.  We have you covered and have created several examples that we want you to copy, paste, and mash up into your applications.  Show us what you can do!</p>
<ul>
<li>Sensor Examples: <a href="https://github.com/blackberry/Cascades-Samples">https://github.com/blackberry/Cascades-Samples</a></li>
<li>User documentation: <a href="http://blackberry.github.com/Cascades-Samples">http://blackberry.github.com/Cascades-Samples</a></li>
</ul>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/11629/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/11629/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11629&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/10/sensors-on-blackberry-10-have-arrived/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/25ee80c29143f159bad70d24df820bc1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shadidhaque</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/10/embed.png" medium="image">
			<media:title type="html">embed</media:title>
		</media:content>
	</item>
		<item>
		<title>Bringing your BlackBerry PlayBook apps to BlackBerry 10</title>
		<link>http://devblog.blackberry.com/2012/05/blackberry-playbook-apps-on-blackberry-10/</link>
		<comments>http://devblog.blackberry.com/2012/05/blackberry-playbook-apps-on-blackberry-10/#comments</comments>
		<pubDate>Wed, 09 May 2012 17:32:51 +0000</pubDate>
		<dc:creator>russellandrade</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[apis]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[blackberry playbook]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[native]]></category>
		<category><![CDATA[native apps]]></category>
		<category><![CDATA[Native Development Kit]]></category>
		<category><![CDATA[native sdk]]></category>
		<category><![CDATA[orientation]]></category>
		<category><![CDATA[porting]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9160</guid>
		<description><![CDATA[Going over two important upcoming changes to the BlackBerry 10 Native SDK in order to help developers prepare for upcoming releases, and examining how developers can easily port their BlackBerry PlayBook tablet apps to BlackBerry 10.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9160&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>While all the SDKs for <a href="http://blogs.blackberry.com/2012/05/blackberry-10-world-keynote/" target="_new">BlackBerry®</a> 10 are amazing, our pride and joy is the BlackBerry 10 Native SDK. If you’ve built native apps for the <a href="http://www.blackberry.com/playbook" target="_new">BlackBerry® PlayBook™</a> tablet, then you’ve used our BlackBerry Native SDK for Tablet OS. The new BlackBerry 10 Native SDK has the same underlying framework as the NDK platform and exposes many new APIs and tooling that will make your development experience even better. If you haven’t had a chance to download and write apps for the BlackBerry PlayBook tablet yet, now is a great time to start building some apps.</p>
<p>One of our priorities is to make sure that apps written with the BlackBerry Native SDK for Tablet OS will transition with minimal hassle to our BlackBerry 10 platform. We don’t want you, our <a href="http://www.blackberry.com/developer" target="_new">developer community</a>, to have to reinvent the wheel or tweak significant amounts of code. We also want to make sure that our developers are aware of changes coming to the platform that may impact them so they can prepare accordingly. With that in mind, I want to talk about two important upcoming changes to the BlackBerry 10 Native SDK in order to help developers prepare for upcoming releases. The motivation for both changes is to help developers scale their apps from tablets to phones.</p>
<p><span id="more-9160"></span></p>
<p>The first change has to do with multi-icon support. We want to create a seamless way for developers to port their BlackBerry PlayBook tablet applications to the BlackBerry 10 smartphone. As we support two device screen sizes, applications may need to provide more than one icon size depending on the device they are being installed on. Developers will now be able to specify a list of icons and splash screens per locale and per resolution in the bar descriptor. These would be of various sizes to suit the different target displays. The runtime will then choose the icon and splash screen that matches the given display. We will be maintaining backwards compatibility, so existing apps written for the BlackBerry PlayBook tablet should not have to modify anything. However, if you are moving your app to a BlackBerry 10 device, you will have to specify icons and splash screens with alternate sizes.</p>
<p>The second important change is with respect to orientation. On BlackBerry 10, native applications will not be able to get the width and height values that they need for sizing their windows and determining orientation by querying the ‘WIDTH’ and ‘HEIGHT’ environment variables. If the width is greater than the height, the application will know it is running in landscape mode and vice versa. This behaviour has changed from BlackBerry PlayBook OS 2.0. On BlackBerry PlayBook OS 2.0, an application would query the screen APIs to get its width and height. For applications running on BlackBerry PlayBook OS 2.0, they can continue to rely on this behaviour as this is now going to change. On BlackBerry 10, however, applications are discouraged from querying for their width and height using the screen APIs. The following code snippet illustrates how an app can query for its width and height:</p>
<p><code>int screen_resolution[2];<br />
screen_resolution[0] = atoi(getenv("WIDTH")); //get width<br />
screen_resolution[1] = atoi(getenv("HEIGHT")); //get height</code></p>
<p>Once the application gets these values (which it can and should do at startup), the application can proceed to create and set up its window.</p>
<p><code>screen_create_window(&amp;window, context);<br />
rc = screen_set_window_property_iv(window,<br />
SCREEN_PROPERTY_SIZE, screen_resolution);<br />
if (rc) {<br />
//handle error …<br />
}</code></p>
<p>rc = screen_set_window_property_iv(screen_win,<br />
SCREEN_PROPERTY_BUFFER_SIZE, screen_resolution);<br />
if (rc) {<br />
//handle error …<br />
}</p>
<p>Applications written for BlackBerry 10 should not set the SCREEN_PROPERTY_ROTATION value, as Navigator will set this for the application automatically when it posts its window.</p>
<p>Furthermore, if you were writing native apps on BlackBerry PlayBook OS 2.0, you would have had to write extra logic to rotate your window based on what you read out from the “ORIENTATION” environment variable. The box below shows an example of how orientation was set up in the BlackBerry PlayBook OS 2.0 setup. This code can now be removed, thereby simplifying your setup logic.</p>
<p><code>//THIS CODE CAN NOW BE DELETED</code></p>
<p>int angle = atoi(getenv(&#8220;ORIENTATION&#8221;));<br />
int buffer_size[2] = {screen_resolution[0], screen_resolution[1]};<br />
int flip = false;</p>
<p>if ((orientation == LANDSCAPE) &amp;&amp; (buffer_size[0] &lt;<br />
buffer_size[1])) {<br />
//In landscape, rotate to portrait<br />
buffer_size[0] = screen_resolution[1];<br />
buffer_size[1] = screen_resolution[0];</p>
<p>if ((angle == 0) || (angle == 180)) {<br />
//Landscape device in landscape mode<br />
angle = 90;<br />
} else if ((angle == 90) || (angle == 270)) {<br />
//Portrait device in landscape mode<br />
angle = 0;<br />
}</p>
<p>flip = true;<br />
}</p>
<p>if (flip) {<br />
rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION,<br />
&amp;angle);<br />
if (rc) {<br />
//handle error …<br />
}</p>
<p>rc = screen_set_window_property_iv(screen_win,<br />
SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);<br />
if (rc) {<br />
//handle error …<br />
}<br />
}</p>
<p>When it comes to determining current orientation, applications should always rely on the navigator to present current orientation. You should never use the accelerometer to determine orientation. The navigator will also inform the application when it needs to rotate and will initiate the rotation sequence by sending the application a rotate (PORTRAIT or LANDSCAPE) message. These new “rotate” messages are replacing the “orientation” messages on the current 2.0 Navigator. It is to be noted as well that the old orientation messages used to specify rotation in angles, while rotation will be specified as Landscape or Portrait in the new messages. These new units are much more intuitive in my opinion and map more closely with how we think of orientation on the device.</p>
<p>As a native app developer, there are several things you need to consider:</p>
<ul>
<li>Continuing to support your application on BlackBerry PlayBook OS 2.0 won’t require any change – things will continue to work as before.</li>
<li>If you are developing a native app only for BlackBerry 10, you should make sure to use the new method of getting width and height parameters from navigator as well as using the new rotate messages.</li>
<li>If you already have an app on BlackBerry PlayBook OS 2.0 and want to move it to BlackBerry 10, you will have some minor changes to make to port your app over. Your code on BlackBerry PlayBook OS 2.0 will not be able to get the width/height parameters via environment variables, so you will continue to use the old methods. On BlackBerry 10, you should use the parameters you receive from navigator for this.</li>
</ul>
<p>These changes are not drastic, and our hope is that you will be able to migrate from BlackBerry PlayBook OS 2.0 to BlackBerry 10 with minimal fuss. In passing, I should also point out that these changes target developers who are writing applications right on top of our low-level windowing framework, so these changes mainly impact game developers. If you are writing a Cascades™-based application, you should also be abstracted from most of these changes and should consult your Cascades documentation.</p>
<p>I am personally excited about these changes as they will enhance the development capabilities of the BlackBerry 10 Native SDK when it comes to supporting multiple resolutions and orientation. When the time comes for you to start developing or moving your app or game over to the BlackBerry 10 platform, you should definitely consult the developer documentation for more details on these two features and how they will impact your application.</p>
<p>Happy developing!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9160&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/05/blackberry-playbook-apps-on-blackberry-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/aacfb04e6b02273d991e7bb0c519fdec?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">russellandrade</media:title>
		</media:content>
	</item>
	</channel>
</rss>
