<?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; code</title>
	<atom:link href="http://devblog.blackberry.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Fri, 24 May 2013 15:08:31 +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; code</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>Integrating NFC into your BlackBerry 10 Application</title>
		<link>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/</link>
		<comments>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/#comments</comments>
		<pubDate>Thu, 25 Oct 2012 15:34:13 +0000</pubDate>
		<dc:creator>mdwrim</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Near Field Communication]]></category>
		<category><![CDATA[nfc]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[use case]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=11782</guid>
		<description><![CDATA[Guest post from John Murray &#8211; Ed. You know, working in the Developer Relations team at Research In Motion® (RIM®), you get to get to play around with some fun stuff. Recently, Near Field Communication (NFC) has been exercising my brain cells. Some of you may be familiar with the NFC-related articles and code samples [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11782&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><i>Guest post from John Murray &#8211; Ed.</i></p>
<p>You know, working in the Developer Relations team at Research In Motion® (RIM®), you get to get to play around with some fun stuff. Recently, Near Field Communication (NFC) has been exercising my brain cells. Some of you may be familiar with the NFC-related articles and code samples that I’ve co-authored with my co-conspirator, Martin Woolley (<a href="http://twitter.com/mdwrim" target="_new">@mdwrim</a>), which you can find listed in our <a href="http://supportforums.blackberry.com/t5/Java-Development/NFC-Article-and-Code-Index/ta-p/1538775" target="_new">NFC Article and Code index</a>.</p>
<p>Now, whenever you mention NFC in a conversation, people invariably think of payments. Using NFC to make secure payments is perhaps the most obvious use case. However, when I think of NFC I tend to think of workflows as well. “Workflows,” you say? What do you mean?</p>
<p>OK, let’s think about it anecdotally. How many times have you had the challenge of transcribing some data from an external source to your handset whilst holding a bag and trying to hold a conversation at the same time? How many times have you tried to share information on your handset with someone else and had to struggle with inputting email addresses whilst doing three other things at the same time? These use cases are examples of Workflows, or Business Processes, that stumble on the point of having to accommodate more “human” interaction than is really necessary. NFC can be used to help streamline simple workflows that involve human interactions on mobile devices and ultimately help achieve efficiencies.</p>
<p><span id="more-11782"></span></p>
<p>So, having thought about this and how to demonstrate a simple but realistic use case (whilst also having some fun), we came up with the concept of the “Fun Run”.</p>
<p>Suppose you’re taking part in a charity “Fun Run” – not quite a marathon but something shorter for fun. The race organizers have developed a simple mobile application to allow you to register for the event and have placed NFC Tags in the starting and finishing areas. As you start you tap on one of the tags, your race timer is started as well as notifying the organizers that you have begun. When you pass the finish line, simply tap on one of the tags in the Finish area to stop your timer and notify the organizers of your finishing time!</p>
<p>In between the start and finish, there may be Way Points with NFC Reader devices that can be used to register intermediate times as the runner passes these points. Tap the handset to the NFC Reader and receive confirmation that the timing data has been transferred successfully.</p>
<p>OK, maybe it’s not 100% realistic, but as an example it is sufficient to demonstrate how a workflow process that involves having to record start and finish times and tracking progress can be made more efficient using NFC. The key learning point is to understand how integrating NFC technology into your application can be used to achieve efficiencies in similar processes.</p>
<h3><strong>The Applications</strong></h3>
<p>Let’s take a look at how we implemented this simple example using BlackBerry® 10 and BlackBerry® 7 NFC capable devices. There are really three use cases:</p>
<p>1. Tap your handset against an NFC tag at the start of the race to start your race timer.<br />
2. Tap your handset against NFC readers at intermediate waypoints during the race to transfer your current race timer data to an application that manages the reader.<br />
3. Tap your handset against an NFC tag at the end of the race to stop your race timer.</p>
<h3><strong>Acting on External Tag Events</strong></h3>
<p>To implement the first and last use case, we decided to provide two NFC tags that had specific NDEF messages as their content. There would be one tag that would start the timer at the start of the race and one tag that would stop the timer at the end of the race.</p>
<p>Specifically the data in the two tags is:</p>
<p><strong>1. Tag used to start the timer:</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;start&#8221;</p>
<p><strong>2. Tag used to stop the timer:</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;stop&#8221;</p>
<p>Why use this data? Well, firstly we choose an NDEF TNF (Type Name Format) for the NDEF Message because it allows us to define custom tag content that won’t clash with standard tag message types such as Smart Poster (“Sp”) or URL (“U”) or Text (“T”). We want to make sure that when one of these tags is presented, our application, and our application alone, is launched to process the tag.</p>
<p>Secondly, we choose a “Type” of &#8220;<strong>my.rim.com:myrecordtype</strong>&#8220;. Within the context of an External TNF record the Type can be arbitrary, but in order to prevent clashes with other organizations’ custom tag formats, we use the DNS naming scheme to set the namespace of the tag as “<strong>my.rim.com</strong>” to establish it as a RIM NDEF message. We further qualify it with a specific sub-type of “<strong>myrecordtype</strong>” since an organization may define a whole family of custom tag formats for its own use.</p>
<p>So, these settings ensure that these tags will only make sense to our application and not overlap with tags form elsewhere. The “Payload” of the two tags differs in that one has the string “<strong>start</strong>” and the other has the string “<strong>stop</strong>” to mark them as ones to be used to start and stop the timers respectively.</p>
<p>In the case of BlackBerry 10, our application registered with the Invocation Framework through the stanza in its “<strong>bar-descriptor.xml</strong>” file as shown in Figure 1. The “<strong>uris</strong>” attribute of the “<strong>&lt;property &#8230; /&gt;</strong>” tag has been set to the value “<strong>ndef://4/my.rim.com/myrecordtype</strong>” which a URI format specification of the two tags just described above.</p>
<pre>...
&lt;invoke-target id="com.example.NfcRaceTimeWay"&gt;
    &lt;type&gt;APPLICATION&lt;/type&gt;
    &lt;filter&gt;
        &lt;action&gt;bb.action.OPEN&lt;/action&gt;
        &lt;mime-type&gt;application/vnd.rim.nfc.ndef&lt;/mime-type&gt;
        &lt;property var="uris" value="ndef://4/my.rim.com/myrecordtype"/&gt;
    &lt;/filter&gt;
&lt;/invoke-target&gt;
...</pre>
<p style="text-align:center;">Figure 1 Registering for tag types in BlackBerry 10</p>
<p>When a “start” or “stop” tag is presented to the handset, then our application is launched if it’s not already running, and the tag contents are handled as shown in Figure 2 &#8212; where the payload of “start” or “stop” is extracted once we’ve verified that it’s of the correct type.</p>
<pre>...
void NfcListener::receivedInvokeRequest(const bb::system::InvokeRequest&amp; request) {

    QByteArray data = request.data();
    QtMobilitySubset::QNdefMessage ndefMessage = QtMobilitySubset::QNdefMessage::fromByteArray(data);

    handleNdefRequest(ndefMessage);
}

void NfcListener::handleNdefRequest(const QtMobilitySubset::QNdefMessage ndefMessage) {

    QList::const_iterator ndefRecord;

    for ( ndefRecord = ndefMessage.begin(); ndefRecord != ndefMessage.end(); ndefRecord++) {
        if (ndefRecord-&gt;typeNameFormat() == QtMobilitySubset::QNdefRecord::ExternalRtd) {
            if (QString(ndefRecord-&gt;type()).compare("my.rim.com:myrecordtype") == 0 ) {
                emit raceTagDetected(QString(ndefRecord-&gt;payload()));
            }
        }
    }
}
...</pre>
<p style="text-align:center;">Figure 2 Handling a Start or Stop tag in BlackBerry 10</p>
<p>In the case of BlackBerry 7, registration is achieved in Java® by registering a listener for the specific NDEF message type as shown in Figure 3.</p>
<pre>...
    nfcManager = ReaderWriterManager.getInstance();
    nfcManager.addNDEFMessageListener(listener, NDEFRecord.TNF_EXTERNAL, "my.rim.com:myrecordtype", true);
...</pre>
<p style="text-align:center;">Figure 3 Registering for tag types in BlackBerry 7</p>
<p>A similar behaviour is achieved for BlackBerry 7 through the implementation of the “<strong>onNDEFMessageDetected()</strong>” method of the “<strong>NDEFMessageListener</strong>” interface as shown in Figure 4.</p>
<pre>...
    public void onNDEFMessageDetected(NDEFMessage msg) {
        NDEFRecord[] records = msg.getRecords();
        int numRecords = records.length;
        if(numRecords &gt; 0) {
            byte[] payloadBytes = records[0].getPayload();
            try {
                String ascii_payload = new String(payloadBytes,"US-ASCII");
                Utilities.log("XXXX payload="+ascii_payload);
                if (ascii_payload.equals("start")) {
                    startTimer();
                }
                if (ascii_payload.equals("stop")) {
                    stopTimer();
                }
            } catch(UnsupportedEncodingException e) {
                Utilities.log("XXXX "+e.getClass().getName()+":"+e.getMessage());
            }
        }

    }

...</pre>
<p style="text-align:center;">Figure 4 Handling a Start or Stop tag in BlackBerry 7</p>
<p>So, what we’ve achieved here is the ability to use an external NFC tag to trigger a process in our application. In this case it’s simply the starting and stopping of a timer, but it could be extended quite easily to, say, call a web service and integrate the event into a larger workflow process.</p>
<p>What does this look like in practice? Well, here’s a short video of the BlackBerry 10 application in action:</p>
<p style="text-align:center;"><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='480' height='360' src='http://www.youtube.com/embed/QZ5nABZcFuo?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p style="text-align:center;">[ <a href="http://www.youtube.com/watch?v=QZ5nABZcFuo&amp;feature=youtu.be" target="_new">YouTube link for mobile viewing</a> ]</p>
<h3><strong>Virtual Tag Emulation</strong></h3>
<p>Let’s get back to the original use cases. To implement the second one, we decided to have the BlackBerry handset emulate a virtual tag and allow the contents of the virtual tag to be read by an external NFC reader.<br />
What format of tag should be emulated by the handset? This is what we chose:</p>
<p><strong>1. Virtual tag emulated by the application</strong></p>
<p>NDEF TNF = External ( integer value 4 )<br />
Type = &#8220;my.rim.com:myrecordtype&#8221;<br />
Payload = &#8220;hh:mm:ss&#8221;</p>
<p>a. That is the time displayed on the handset in:<br />
Hours (hh)<br />
Minutes (mm)<br />
Seconds (ss)</p>
<p>The type of the virtual tag is exactly the same as for the “start” and “stop” physical tags for the very same reasons, except that the payload is a representation of the current race timer value (“hh:mm:ss”) as displayed by the application.</p>
<pre>...
void NfcListener::startTagEmulation(const QString &amp;tagData) {
    nfc_ndef_record_t *ndefRecord = makeCustomRecord(QString("my.rim.com"), QString("myrecordtype"), tagData);
    if (_emulateNdefMessage) {
        CHECK(nfc_delete_ndef_message(_emulateNdefMessage, true));
        _emulateNdefMessage = 0;
    }
    CHECK(nfc_create_ndef_message(&amp;_emulateNdefMessage));
    CHECK(nfc_add_ndef_record(_emulateNdefMessage, ndefRecord));
    CHECK(nfc_start_ndef_tag_emulation(_emulateNdefMessage));
...</pre>
<p style="text-align:center;">Figure 5 BlackBerry 10 &#8211; starting virtual tag emulation</p>
<p>As shown in Figure 5, starting tag emulation in BlackBerry 10 is quite simple. It just involves calling “<strong>nfc_start_ndef_tag_emulation()</strong>”. In addition we can use BPS (BlackBerry Platform Services) to determine when a read on the virtual tag has been successful, as shown here in Figure 6:</p>
<pre>...
void NfcListener::handleNfcEvent(bps_event_t *event) {
    uint16_t code = bps_event_get_code(event);
    if (NFC_VIRTUAL_TAG_SELECTION_EVENT == code) {
        emit tagEmulationSelectEvent();
    } else if (NFC_VIRTUAL_TAG_LEFT_EVENT == code) {
        emit tagEmulationLeftEvent();
    } else if (NFC_VIRTUAL_TAG_READ_EVENT == code) {
        emit tagEmulationReadEvent();
    }
}
...</pre>
<p style="text-align:center;">Figure 6 BlackBerry 10 &#8211; stopping virtual tag emulation</p>
<p>So, what we’ve achieved here is the ability to transmit live information from an application in the BlackBerry handset in real time to an external application via an NFC reader. The external application simply displays the time displayed by the BlackBerry application, but it could easily be extended to integrate with some larger workflow process.</p>
<p>Take a look at the video here for a demonstration of this on BlackBerry 10:</p>
<p style="text-align:center;"><span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='480' height='360' src='http://www.youtube.com/embed/g58Xpnsqq4o?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span></p>
<p style="text-align:center;">[ <a href="http://www.youtube.com/watch?v=g58Xpnsqq4o&amp;feature=youtu.be" target="_new">YouTube link for mobile viewing</a> ]</p>
<p>If you’re interested, the virtual tag emulation functionality was tested using an NFC Reader attached to a PC controlled by a Python application using the “PyScard” (Python for Smart Cards) library available from <a href="http://pyscard.sourceforge.net/" target="_new">SourceForge.net</a>. (Python and Ruby are my favorite programming languages!)</p>
<p>The two versions of our NFC-enabled “Fun Run” applications are available with full source code from our GitHub repositories here:</p>
<p><a href="https://github.com/blackberry/Cascades-Community-Samples/tree/master/NfcRaceTimeWay" target="_new">https://github.com/blackberry/Cascades-Community-Samples/tree/master/NfcRaceTimeWay</a><br />
<a href="https://github.com/blackberry/Samples-for-Java/tree/master/NFC/NfcRaceTime7" target="_new">https://github.com/blackberry/Samples-for-Java/tree/master/NFC/NfcRaceTime7</a></p>
<p>Just in closing, it’s worth making one or two comments about the relative ease of developing applications to the same set of end user specifications in BlackBerry 10 Cascades™ versus BlackBerry 7 Java. I’ve been developing code in C/C++ for more years than I care to remember and for a shorter time in Java (but still since the language first saw the light of day), so I feel I’m qualified to make comparisons. I’ll be honest: I’ve found it much easier to develop applications using C/C++ and Cascades. The user interface elements are particularly easy to use, and I’ve found it possible to get a user interface up and running in Cascades much faster than I would have done in Java. It’s much easier to modify and extend since Cascades elements map directly to Qt/Cascades C++ classes and the SIGNAL() / SLOT() model makes it so easy to connect events to handlers.</p>
<p>I’m definitely sold on Cascades, Qt and C/C++!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/11782/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/11782/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11782&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/10/blackberry-10-app-nfc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d86c7fdd0d15b754b2760af4536923b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mdwrim</media:title>
		</media:content>
	</item>
		<item>
		<title>bbUI.js version 0.9.4 has landed</title>
		<link>http://devblog.blackberry.com/2012/10/bbui-js-update/</link>
		<comments>http://devblog.blackberry.com/2012/10/bbui-js-update/#comments</comments>
		<pubDate>Fri, 19 Oct 2012 15:34:14 +0000</pubDate>
		<dc:creator>Tim N.</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[Java Development]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[bbui.js]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=11771</guid>
		<description><![CDATA[After a bunch of hard work, bbUI version 0.9.4 is finally here. The focus in this release has really been around bug fixes, optimizations and additional JavaScript® interfaces. The previous versions of bbUI have been VERY declarative and haven’t allowed for much manipulation after the fact via JavaScript. This release takes a step in the [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11771&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-9170" title="" alt="TITLE_IMAGE" src="http://rimdevblog.files.wordpress.com/2012/05/bbui-1.jpg?w=500&#038;h=124" height="124" width="500" /></p>
<p>After a bunch of hard work, <a href="https://github.com/blackberry/bbUI.js" target="_new">bbUI version 0.9.4 is finally here</a>. The focus in this release has really been around bug fixes, optimizations and additional JavaScript® interfaces. The previous versions of bbUI have been VERY declarative and haven’t allowed for much manipulation after the fact via JavaScript. This release takes a step in the right direction to allow you to create more dynamic user interfaces via JavaScript. While there are some improvements in this department with v0.9.4, we’re not finished yet and have much more planned for <a href="https://github.com/blackberry/bbUI.js/issues?milestone=9&amp;page=1&amp;state=open" target="_new">v0.9.5</a>.</p>
<p>One of the best things I’ve seen lately is the number of people participating in the project. It’s absolutely fantastic to see members of the community grab items from the roadmap, implement them and send them back as pull requests. These pull requests are full on feature creation as well as bug fixes. A gigantic THANK YOU goes out to all those who are helping to improve bbUI!</p>
<p>Be sure to <a href="https://github.com/blackberry/bbUI.js/blob/master/CHANGELOG.md" target="_new">check out the full change log</a> for this release to know what kind of adjustments you may need to make to your JavaScript in order to run v0.9.4, and <a href="https://github.com/blackberry/bbUI.js/issues?milestone=6&amp;page=1&amp;state=closed" target="_new">check out the closed issues</a> for details on bugs that have been fixed and features that have been added. The v0.9.4 JavaScript changes are fairly minor and are meant to make your life easier as we continue to move forward.</p>
<p><span id="more-11771"></span></p>
<h3><strong>Notable Improvements</strong></h3>
<ul>
<li>Updated coloring/styling to better match Cascades™</li>
<li>New <a href="https://github.com/blackberry/bbUI.js/wiki/Screens" target="_new">Title Bar</a> styling which now allows images in the Title Bar</li>
<li>New BlackBerry® PlayBook™ tablet 2.x styling for Activity Indicators, Text Input, Image Lists and Buttons</li>
<li>Many new JavaScript interfaces to manipulate controls on-the-fly</li>
<li>Native <a href="http://www.youtube.com/watch?v=GgtsgVtB0yA&amp;feature=youtu.be" target="_new">scrolling speed increases</a></li>
<li>Screen stack bug fixes</li>
<li>Control bug fixes</li>
</ul>
<h3><strong>Changes to your code</strong></h3>
<p>I mentioned that there were a few changes that were made that will affect your applications JavaScript so let’s talk about those.</p>
<ul>
<li>bb.init()
<ul>
<li>bb10ActionBarDark renamed to actionBarDark</li>
<li>bb10ControlsDark renamed to controlsDark</li>
<li>bb10ListsDark renamed to listsDark</li>
<li>bb10HighlightColor renamed to highlightColor</li>
</ul>
</li>
<li>You no longer specify a viewport meta tag in your main index.htm. This is now supplied by the toolkit at runtime based on the OS version.</li>
<li>BlackBerry® 10 title bars now take on the control coloring.</li>
<li>You no longer need to specify a unique id for your script tags used with screens.</li>
<li><a href="https://github.com/blackberry/bbUI.js/wiki/Scroll-Panel" target="_new">Scroll Panel</a> JavaScript interfaces have been modified.</li>
<li>If you were calling bb.scroller.refresh() you will want to change your code to &#8220;if (bb.scroller) bb.scroller.refresh();&#8221;</li>
</ul>
<h3><strong>More to Come</strong></h3>
<p>We’ve now created an additional <a href="https://github.com/blackberry/bbUI.js/issues?milestone=9&amp;page=1&amp;state=open" target="_new">v0.9.5 milestone for bbUI</a> that contains additional BlackBerry 10 styling improvements, but also includes more JavaScript interfaces for dynamic screen creation and manipulation. If you’re interested in following the bbUI.js changes as they go, <a href="https://twitter.com/brcewane" target="_new">feel free to follow me on Twitter®</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/11771/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/11771/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=11771&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/10/bbui-js-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3939390650b170ba28e9bf3c53d397ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timneil1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/bbui-1.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>
	</item>
		<item>
		<title>Hello OggVorbis</title>
		<link>http://devblog.blackberry.com/2012/08/hello-oggvorbis/</link>
		<comments>http://devblog.blackberry.com/2012/08/hello-oggvorbis/#comments</comments>
		<pubDate>Tue, 07 Aug 2012 16:48:39 +0000</pubDate>
		<dc:creator>Ramprasad Madhavan</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[OggVorbis]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[OpenAL]]></category>
		<category><![CDATA[sample code]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10567</guid>
		<description><![CDATA[Using a sample project to show how to set up and use OpenAL and OggVorbis with the BlackBerry 10 Native SDK.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10567&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The audio portion of a native game or app has traditionally been a land of &#8220;#ifdefs&#8221; and low-level platform specific code. This is especially true when targeting different devices supporting differing audio formats.</p>
<p>OpenAL, from Khronos, is designed to solve that exact problem. It is an open source, cross platform 3D Sound API for use in games and multimedia apps. Thankfully, OpenAL 1.1 is readily available on BlackBerry® 10. It is supported on multiple platforms and due to its API looking strikingly similar its 3D graphics cousin OpenGL API, it has proved to be very easy to learn and integrate. OpenAL, however, does not directly support compressed audio formats out-of-the-box. This could result in games having bigger audio files and hence a bigger memory footprint.</p>
<p>Enter OggVorbis.</p>
<p>There are several compressed audio formats and associated libraries available and I recommend OggVorbis for the following reasons:</p>
<ul>
<li>It’s lightweight</li>
<li>It’s open source</li>
<li>It’s professional quality audio encoding</li>
<li>It’s streaming support</li>
</ul>
<p>If you need further convincing, please visit <a href="http://www.vorbis.com/faq/" target="_new">their site</a>.</p>
<p>This blog post uses a sample project to show how to set up and use OpenAL and OggVorbis with the BlackBerry 10 Native SDK. The sample is forked off the famous &#8220;cascades cowbell app&#8221; and minor modifications have been made to show how to load and play .ogg and .wav files. Assuming you are already familiar with the BlackBerry 10 Native SDK, here are the main steps to follow:</p>
<p><span id="more-10567"></span></p>
<h3><strong>Convert your assets</strong></h3>
<p>Download a tool of your choice from <a href="http://www.vorbis.com/software" target="_new">http://www.vorbis.com/software</a> to convert the heavy WAV PCM files to the slender OGG files.</p>
<h3><strong>Add the OggVorbis library to your project</strong></h3>
<p>OggVorbis is already ported and available at the BlackBerry Github community, so go ahead download the <a href="https://github.com/blackberry/OggVorbis" target="_new">source code</a> <code>()</code> and compile it using BlackBerry 10 Native SDK. Once compiled, add the library (example: libvorbis.a) and the headers into a folder inside the cowbell application project directory. Let&#8217;s call it &#8220;external-lib&#8221;. Now modify the cowbell.pro project to include the header and library files.</p>
<pre>LIBS   += -lOpenAL -lalut -L../external-lib/oggvorbis/lib/qnx/arm/ -L../external-lib/oggvorbis/lib/qnx/x86/ -lvorbis

INCLUDEPATH += ../src ../external-lib/oggvorbis/include
SOURCES += ../src/*.cpp 
HEADERS += ../src/*.h</pre>
<p>Now that we have the project setting done, we can focus on loading and playing the .ogg file.</p>
<h3><strong>Open the OGG file</strong></h3>
<p>The function that opens up the access to the OggVorbis file is <code>ov_open</code>. Declare an <code>OggVorbis_File</code> file type that is returned by the ov_open. This file will be used to decode the OggVorbis file.</p>
<pre>OggVorbis_File ogg_file;
ALenum format;
int result;
unsigned int size = 0;

rewind(file);

// Open the ogg file
if (ov_open(file, &amp;ogg_file, NULL, 0) &lt; 0)
fclose(file);</pre>
<h3><strong>Calculate the unpacked audio file size</strong></h3>
<p>In order to load the uncompressed data into an OpenAL buffer, we need to store the audio data in a temporary buffer. The size of the audio buffer can be found using a simple formula: (<em>number of channels</em>) * (<em>number of samples</em>) * (<em>number of bytes per packet</em>)</p>
<p>The number of channels info can be retrieved into vorbis_info using the ov_info function. The number of samples can be found using the ov_pcm_total function.</p>
<pre>vorbis_info* info;
// Get the file info for creating the audio buffer
info = ov_info(&amp;ogg_file, -1);

if (info-&gt;channels == 1)
	format = AL_FORMAT_MONO16;
else
	format = AL_FORMAT_STEREO16;

// buffer size = (no. of channels) * (no. of samples) * 2 (for 16 bit)
unsigned int data_size = ov_pcm_total(&amp;ogg_file, -1) * info-&gt;channels * 2;</pre>
<h3><strong>Decode the audio file</strong></h3>
<p>Once we have a temp buffer allocated, the <code>ov_read</code> function can be used to read and decode blocks of audio data.</p>
<pre>char* data = new char[data_size];

// Read the Ogg file into audio buffer
while (size &lt; data_size) {
	result = ov_read(&amp;ogg_file, data + size, data_size - size, 0, 2, 1, &amp;section);
	if (result &gt; 0)
		size += result;
	else if (result &lt; 0) {
		delete data;
		return false;
	}
	else {
		break;
	}
}</pre>
<h3><strong>Load the data into an OpenAL buffer</strong></h3>
<p>Assuming we have already initialized OpenAL context and audio buffers to hold audio data, we can now upload the unpacked data into it.</p>
<pre>// Load PCM data into OpenAL buffer.
alBufferData(buffer, format, data, data_size, info-&gt;rate);

ALenum error = alGetError();
if (error != AL_NO_ERROR)
	reportOpenALError(error);</pre>
<p>Playing the audio is no different than playing regular PCM audio data.</p>
<p>The full sample is available under an Open Source license at <a href="https://github.com/blackberry/Cascades-Community-Samples/tree/master/HelloOggVorbis" target="_new">here</a>. Enjoy and consider participating in our Open Source community</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10567/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10567/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10567&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/08/hello-oggvorbis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/ba5492209a7823e5998202d3e638830d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rmadhavan</media:title>
		</media:content>
	</item>
		<item>
		<title>bbUI.js version 0.9.3 now available</title>
		<link>http://devblog.blackberry.com/2012/07/bbui-js-version-0-9-3-now-available/</link>
		<comments>http://devblog.blackberry.com/2012/07/bbui-js-version-0-9-3-now-available/#comments</comments>
		<pubDate>Fri, 20 Jul 2012 13:52:36 +0000</pubDate>
		<dc:creator>Tim N.</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[bbui.js]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[improvements]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10122</guid>
		<description><![CDATA[There's a new update for bbUI.js now available through Github.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10122&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><img class="aligncenter size-full wp-image-9170" src="http://rimdevblog.files.wordpress.com/2012/05/bbui-1.jpg?w=500&#038;h=124" alt="TITLE_IMAGE" width="500" height="124" /></p>
<p>We’ve been receiving lots of great feedback on the bbUI framework as we’ve been continuing the <a href="http://www.blackberryjamworldtour.com/" target="_new">BlackBerry® 10 Jam World Tour</a>. Thank you all for your constant collaboration and continuous feedback! We even had a chance to receive a feature request during the morning of the Toronto stop and implement a new <a href="https://github.com/blackberry/bbUI.js/wiki/Scroll-Panel" target="_new">scrolling panel feature</a> by the end of that same day <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>This release looks to further close the gap between what’s being offered in the Cascades™ UI framework and what’s available in bbUI.</p>
<p>Be sure to check out <a href="https://github.com/blackberry/bbUI.js/blob/master/CHANGELOG.md" target="_new">the full change log</a> for this release to know what kind of adjustments you may need to make to your markup in order to run v0.9.3 and check out <a href="https://github.com/blackberry/bbUI.js/issues?milestone=8&amp;page=1&amp;state=closed" target="_new">the closed issues</a> for bugs that have been fixed. The v0.9.3 markup changes are fairly minor and are meant to make your life easier as we continue move forward.</p>
<p><span id="more-10122"></span></p>
<h3><strong>Notable Improvements:</strong></h3>
<ul>
<li><a href="https://github.com/blackberry/bbUI.js/wiki/Action-Bar" target="_new">Action Bar</a>
<ul>
<li>Now has tab overflow menus</li>
<li>UX updates to match latest Cascades experience</li>
<li>Full control of which items to show on the action bar vs. the overflow menus</li>
<li>Ability to “pin” an action to the bottom of action overflow and context menus</li>
</ul>
</li>
<li><a href="https://github.com/blackberry/bbUI.js/wiki/Image-List" target="_new">Image List</a>
<ul>
<li>Supports multiple new styles such as allowing secondary action buttons for items</li>
<li>Additional JavaScript® interfaces for list manipulation</li>
<li>Adjusted alignment to support “title only” list items</li>
</ul>
</li>
<li>Buttons
<ul>
<li>Now allow for text only | image only | text + image</li>
<li>Additional JavaScript interfaces for button manipulation</li>
</ul>
</li>
<li>BlackBerry® PlayBook™ tablet controls with BlackBerry 10 styling have been re-sized to better fit the device resolution</li>
<li>File Input controls now have BlackBerry 10 styling to appear as a button which launches the browse dialog</li>
<li>Added <a href="https://github.com/blackberry/bbUI.js/wiki/Toggle-Buttons" target="_new">toggle button styling</a> for BlackBerry 10 with some funky animation</li>
<li>New <a href="https://github.com/blackberry/bbUI.js/wiki/Activity-Indicator" target="_new">activity indicator styling</a> for BlackBerry 10</li>
<li>Additional JavaScript interfaces for Title Bar manipulation</li>
<li>Added <a href="https://github.com/blackberry/bbUI.js/wiki/Checkboxes" target="_new">checkbox styling</a> and JavaScript interface for BlackBerry 10</li>
<li>New <a href="https://github.com/blackberry/bbUI.js/wiki/Scroll-Panel" target="_new">scroll panel</a> for master/detail type of views on BlackBerry PlayBook tablet</li>
<li>New sliding screen transitions for BlackBerry 10 and BlackBerry PlayBook tablet styling</li>
<li>Font adjustments now look better when emulating in Ripple</li>
</ul>
<h3><strong>Changes to your code:</strong></h3>
<p>I mentioned that there were a few changes that were made that will affect your application markup so let’s talk about those.</p>
<ul>
<li>Default control color for BlackBerry 10 has been changed from dark to light. You should explicitly state your color choice in the <a href="https://github.com/blackberry/bbUI.js/wiki/Toolkit-Initialization" target="_new">bb.init()</a> function to suit your application’s style</li>
<li>The progress bar’s pause() function has been removed and replaced with setState() to allow for normal, warning and error states</li>
<li>You now must explicitly state which actions/tabs on the Action Bar are to show on the overflow menus</li>
<li>Arrow List control has now been merged as a feature of the image list. You will have to change your existing arrow list markup to image list markup with the proper style attribute</li>
<li>By default a screen’s background color is now white unless you explicitly set its style. This was needed in order to implement the sliding transitions</li>
<li>BlackBerry 10 buttons no longer stretch by default. To stretch you need to set the data-bb-style=”stretch” attribute</li>
<li>Default font has been changed from Slate to Slate Pro for BlackBerry 10</li>
</ul>
<h3><strong>More to Come:</strong></h3>
<p>We’ve now created an additional <a href="https://github.com/blackberry/bbUI.js/issues?milestone=8&amp;state=open" target="_new">v0.9.4 milestone for bbUI</a> that contains additional BlackBerry 10 controls but also includes more JavaScript interfaces for dynamic screen creation and manipulation. It also contains some updates around Tablet user experience. If you’re interested in following the bbUI.js changes as they go, feel free to <a href="https://twitter.com/brcewane" target="_new">follow me on Twitter®</a>.</p>
<p>Okay&#8230;now that we’ve covered what’s new and what’s changed, I think it’s time for some of that good old eye candy <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Image List Additional Styles</strong></p>
<p style="text-align:center;"><img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-1.jpg?w=280" alt="" width="280" /> <img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-2.jpg?w=280" alt="" width="280" /></p>
<p><img class="aligncenter size-full wp-image-10131" title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-3.jpg?w=300&#038;h=480" alt="" width="300" height="480" /></p>
<p><strong>Tab Overflow menu, item centering and action pinning</strong></p>
<p style="text-align:center;"><img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-4.jpg?w=280" alt="" width="280" /> <img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-5.jpg?w=280" alt="" width="280" /></p>
<p><strong>Sample Action Bar Layouts</strong></p>
<p><img class="aligncenter size-full wp-image-10128" title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-6.jpg?w=525&#038;h=311" alt="" width="525" height="311" /></p>
<p><strong>Buttons with Images and Activity Indicators</strong></p>
<p style="text-align:center;"><img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-7.jpg?w=280" alt="" width="280" /> <img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-8.jpg?w=280" alt="" width="280" /></p>
<p><strong>Scrollable Areas for Master/Detail Layout</strong></p>
<p><img class="aligncenter size-full wp-image-10125" title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-9.jpg?w=500&#038;h=305" alt="" width="500" height="305" /></p>
<p><strong>Toggle Buttons and Checkboxes</strong></p>
<p style="text-align:center;"><img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-10.jpg?w=280" alt="" width="280" /> <img title="" src="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-11.jpg?w=280" alt="" width="280" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10122/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10122/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10122&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/07/bbui-js-version-0-9-3-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3939390650b170ba28e9bf3c53d397ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timneil1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/bbui-1.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-1.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-4.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-5.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-6.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-7.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-8.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-9.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-10.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/bbui-093-update-11.jpg" medium="image" />
	</item>
		<item>
		<title>Using the Invocation Framework from ActionScript</title>
		<link>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/</link>
		<comments>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 13:11:44 +0000</pubDate>
		<dc:creator>Tim N.</dc:creator>
				<category><![CDATA[Adobe AIR Development]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[adobe air]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 SDK]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[Invoke Framework]]></category>
		<category><![CDATA[invoking]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10243</guid>
		<description><![CDATA[Examining the Invocation Framework included in the Beta 2 of the BlackBerry 10 SDK for Adobe AIR.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10243&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-10268" title="" src="http://rimdevblog.files.wordpress.com/2012/07/air-invoke.jpg?w=310&#038;h=197" alt="TITLE_IMAGE" width="310" height="197" /></p>
<p>Beta 2 of the BlackBerry® 10 SDK for Adobe® AIR® now has support for participating in the BlackBerry 10 Invoke Framework. You can find all of the APIs in the QNXDevice.ane and they are all documented.</p>
<h3><strong>Invoking a Application</strong></h3>
<p>By leveraging the Invoke API, you can invoke virtually any other application on the BlackBerry® smartphone through some simple API call, where you’ll set a parameter for the app you want to invoke and then pass in any parameters that application is expecting. A typical example would be that your application can invoke the BlackBerry® Maps application when it comes across an address. <code>InvokeManager.invoke()</code> will invoke an application.</p>
<p>When the application has been successfully invoked, an <code>InvokeEvent.INVOKE_TARGET</code> event will be dispatched. If there was an error invoking the target, an <code>ErrorEvent.ERROR</code> event will be dispatched. Please refer to the following <a href="http://supportforums.blackberry.com/t5/Test-Article-and-Discussion/Invocation-APIs-fail-when-using-the-BlackBerry-10-Dev-Alpha/ta-p/1819139/">Knowledge Base article</a> for details on some known issues which will be addressed in an upcoming patch.</p>
<p><span id="more-10243"></span></p>
<h3><strong>Invoking a Viewer</strong></h3>
<p><code>InvokeManager.invokeViewer()</code> will invoke a viewer. A Viewer class is returned and is used to communicate with the viewer.</p>
<p>Let’s say you have an image viewer application and you want to invoke it from the main application you’re working on. In the main application, you want to pass the image file that the imager viewer app will open when invoked.</p>
<p>Below is a sample of how you can invoke a viewer and wait for it to be created. This example assumes that you have created the <code>viewerRequest</code> object with the correct data for your viewer.</p>
<pre>var viewer:Viewer = InvokeManager.invokeManager.invokeViewer( viewerRequest );
viewer.addEventListener( ViewerEvent.VIEWER_CREATED, viewerCreated );

private function viewerCreated( event:ViewerEvent ):void
{
   //viewer is created and ready to communicate with.
}</pre>
<h3><strong>Making your Application an Invoke Handler</strong></h3>
<p>If you are developing an application that can be invoked by another application, you will want to add a listener for the invoke event at the very start of your application. These should be the first lines of your application.<br />
Once you have received the invoke event, you can check the startup mode and get the data that you were invoked with.<br />
Below is a sample of how you would accomplish this:</p>
<pre>InvokeManager.invokeManager.addEventListener(InvokeEvent.INVOKE, onInvoked );
private function onInvoked( event:InvokeEvent ):void
{
    if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE )
    {
        var invokeRequest:InvokeRequest = InvokeManager.invokeManager.startupRequest;
    }
    else if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.VIEWER )
    {
        var viewerRequest:InvokeViewerRequest = InvokeManager.invokeManager.startupViewerRequest;
    }
}</pre>
<h3><strong>Query a list of targets</strong></h3>
<p>You can also query a list of targets or viewers on the device by calling the <code>InvokeManager.queryTargets()</code> method. At some point in the future, this will make a pop-up list in your application that will allow users to select items from the list. For now, it returns the results and it is up to you to use those values in your <code>invoke()</code> and <code>invokeViewer()</code> calls.</p>
<h3><strong>InvokeEvent</strong></h3>
<p>No matter how your application is started, you will receive an InvokeEvent dispatched by the InvokeManager. In order to determine how your app was started, you can check the <code>InvokeManager.startupMode</code> in your InvokeEvent handler. So, your application would look something like the following, assuming that your application can be launched as a target and a viewer:</p>
<pre>package
{
    import qnx.events.InvokeEvent;
    import qnx.invoke.*;

    public class Main extends Sprite
    {

        public function Main()
        {
            //NOTE: THIS MUST BE THE FIRST THING SET IN YOUR APPLICATION CONSTRUCTOR
            InvokeManager.invokeManager.addEventListener(InvokeEvent.INVOKE, onInvoke );
        }

        private function onInvoke( event:InvokeEvent ):void
        {
            if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE )
            {
                //invoked as an application/target.
                var data:InvokeRequest = InvokeManager.invokeManager.startupRequest;
            }
            else if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.VIEWER )
            {
                //invoked as a viewer
                var data:InvokeViewerRequest = InvokeManager.invokeManager.startupViewerRequest;
            }
            else
            {
                //launched by the pressing on the icon on the home screen.
            }
        }
    }
}</pre>
<h3><strong>Closing a Viewer</strong></h3>
<p>There are two different ways a viewer can be closed:</p>
<ol>
<li>From the application</li>
<li>From the viewer</li>
</ol>
<p>When an application wishes to close a viewer that it has created, it can simply call the <code>Viewer.dispose()</code> method. This will cause the viewer to be removed immediately.</p>
<p>A viewer can request to be closed by the application and should never actually attempt to close itself directly. Viewers can call the <code>InvokeManager.requestViewerClose()</code> method. This will send a message to the application requesting that it be closed. The Viewer instance in the application will dispatch a <code>ViewerEvent.VIEWER_CLOSE_REQUEST</code> event. When application receives this event, it should call the <code>dispose()</code> method on the viewer to close it. The reason this doesn’t happen automatically is so that applications can transition viewers out before removing them. We may make this a bit more automated in the future, and we’ll let you know when this happens.</p>
<h3><strong>Viewer message relay</strong></h3>
<p>Viewers can send data to applications using the <code>InvokeManager.viewerSendMessage()</code> method. The Viewer instance will then dispatch <code>ViewerEvent.VIEWER_MESSAGE</code> events with the message and data properties set to what was passed into the <code>viewerSendMessage()</code>. Here is an example of how you would use this:</p>
<h3><strong>Viewer code</strong></h3>
<pre>InvokeManager.invokeManager.viewerSendMessage( "select", {name:"Fred"});</pre>
<h3><strong>App Code</strong></h3>
<pre>__currentViewer = InvokeManager.invokeManager.invokeViewer(viewerRequest);
__currentViewer.addEventListener( ViewerEvent.VIEWER_MESSAGE, onMessage );

private function onMessage( e:ViewerEvent ):void
{
    trace( e.message, e.data ); //outputs "select Fred";
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10243&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3939390650b170ba28e9bf3c53d397ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timneil1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/air-invoke.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>
	</item>
		<item>
		<title>QML/Cascades tip of the day – Property Aliases</title>
		<link>http://devblog.blackberry.com/2012/07/qml-tip-property-aliases/</link>
		<comments>http://devblog.blackberry.com/2012/07/qml-tip-property-aliases/#comments</comments>
		<pubDate>Wed, 18 Jul 2012 13:06:48 +0000</pubDate>
		<dc:creator>Alex Kinsella</dc:creator>
				<category><![CDATA[Cascades]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[property alias]]></category>
		<category><![CDATA[QML]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10246</guid>
		<description><![CDATA[This week's QML/Cascades tip focuses on creating property aliases and why they'll be your friend when creating custom components in QML.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10246&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><em>Here&#8217;s <a href="https://twitter.com/marioboikov">Mario</a> with another handy QML/Cascades tip &#8211; Ed.</em></p>
<p>In today&#8217;s post, I&#8217;ll talk about <em>property aliases</em> and why they&#8217;ll be your friend when creating custom components in QML. I&#8217;ll give you an introduction to the topic by creating a Header component, which consists of a Label and a Divider wrapped inside a Container.</p>
<p>I assume that you already know how to create custom components in QML. Basically you create a new file and name it to whatever the name of your component is, for example &#8216;Header.qml&#8217;. So say we have a file &#8216;Header.qml&#8217; with the following content:</p>
<pre>import bb.cascades 1.0

Container {

    Label {
        id: titleLabel
        text: "Sample Title"
        textStyle.base: SystemDefaults.TextStyles.TitleText
    }

    Divider {
    }
}</pre>
<p><span id="more-10246"></span></p>
<p>To create a Header instance from another QML file, we simply write the following lines:</p>
<pre>...

Header {
}

...</pre>
<p>Looks good, but I assume that we also want to set the title to something more appropriate for the context where the header is to be used. Because we don&#8217;t have direct access to the Label&#8217;s text property from outside the Header component (you can only access top level properties), we need to add a new property to the Container in the Header component:</p>
<pre>import bb.cascades 1.0

Container {
    property string titleText: “Sample Title”

    Label {
        id: titleLabel
        text: titleText
        textStyle.base: SystemDefaults.TextStyles.TitleText
    }

    Divider {
    }
}</pre>
<p>The Label&#8217;s text property binds to the newly added <em>titleText</em> property. Now we can specify a title by setting the titleText property:</p>
<pre>Header {
    titleText: “My Header”
}</pre>
<p>Looks nice and works great, but I&#8217;m still not satisfied. I had to introduce a new property just to be able to specify a title text. What I actually want is to expose the Label&#8217;s <em>text</em> property to users of the Header component. Fortunately there&#8217;s a solution for this, and the name is <em>property alias</em>:</p>
<pre>import bb.cascades 1.0

Container {
    property alias titleText: titleLabel.text

    Label {
        id: titleLabel
        text: “Sample Title”
        textStyle.base: SystemDefaults.TextStyles.TitleText
    }

    Divider {
    }
}</pre>
<p>Much better. We got rid of the <em>titleText</em> property by simply making it an alias to the titleLabel&#8217;s <em>text</em> property instead. Even the instance of the Label can be exposed as an alias, which gives you access to all of the Label&#8217;s properties, if that&#8217;s what you need:</p>
<pre>import bb.cascades 1.0

Container {
    property alias titleLabel: titleLabel

    Label {
        id: titleLabel
        text: “Sample Title”
        textStyle.base: SystemDefaults.TextStyles.TitleText
    }

    Divider {
    }
}</pre>
<p>Now that we have access to all of the Label&#8217;s properties, we can also change the text style:</p>
<pre>Header {
    titleLabel {
        text: “My Title”
        textStyle.base: SystemDefaults.TextStyles.TitleText
    }
}</pre>
<p>Handy, right?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10246&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/07/qml-tip-property-aliases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7d0e94a7e96e80d5911732d43f31a39c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Alex K.</media:title>
		</media:content>
	</item>
		<item>
		<title>Be Social – Integrate your apps with Facebook and Twitter</title>
		<link>http://devblog.blackberry.com/2012/06/integrate-apps-with-social/</link>
		<comments>http://devblog.blackberry.com/2012/06/integrate-apps-with-social/#comments</comments>
		<pubDate>Wed, 06 Jun 2012 13:33:03 +0000</pubDate>
		<dc:creator>Shadid</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Java Development]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[BlackBerry 7]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[sample app]]></category>
		<category><![CDATA[social networks]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9669</guid>
		<description><![CDATA[Find out how to integrate your app with social networks like Facebook and Twitter.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9669&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of the unsung heroes of <a href="http://www.blackberry.com/bb7" target="_new">BlackBerry® 7</a> Java SDK is the Send Command Framework. Although the name doesn’t say much, this API lets you seamlessly integrate with existing apps on the device to share data. Thankfully the native <a href="http://appworld.blackberry.com/webstore/content/680/?lang=en" target="_new">Facebook®</a> and <a href="http://appworld.blackberry.com/webstore/content/8160/?lang=en" target="_new">Twitter®</a> apps are two of many!</p>
<p style="text-align:center;"><img src="http://rimdevblog.files.wordpress.com/2012/05/connected-apps-2.jpg?w=270&#038;h=360" alt="TITLE_IMAGE" width="270" height="360" /> <img title="" src="http://rimdevblog.files.wordpress.com/2012/05/connected-apps-3.jpg?w=270" alt="" width="270" /></p>
<p style="text-align:center;"><em><a href="https://github.com/blackberry/Samples-for-Java/tree/master/SocialApp" target="_new">Download the sample app</a></em></p>
<p>So this is it folks &#8212; no more hair-pulling to figure out how to talk to social networks directly. There are already apps for them, so let’s learn how to leverage those apps from ours instead of reinventing it.</p>
<p><span id="more-9669"></span></p>
<p>The first step is to create the data or context we would like to share. This context is simply a JSON object that encapsulates our data. Here is an example:</p>
<p><code>JSONObject context = new JSONObject();<br />
try {<br />
context.put(SendCommandContextKeys.TEXT, "Your Text");<br />
context.put(SendCommandContextKeys.SUBJECT, "Your Text");<br />
// context.put(SendCommandContextKeys.PATH, "file:///.....");<br />
} catch (JSONException e) {<br />
System.out.println(e.toString());<br />
}</code></p>
<p>I intentionally commented out the PATH type data because we cannot use PATH data in a context that also has TEXT or SUBJECT types. But I still wanted to highlight that we can also share a file path (e.g. a photo).</p>
<p>Once we have our data context nicely wrapped up in a JSONObject, we need to create SendCommand objects that point to specific apps with a specific context. So how do we get these SendCommands? Easy peasy &#8212; we simply query the Send Command Framework with our context data. Here’s how:</p>
<p><code>SendCommand[] commandsAll =<br />
SendCommandRepository.getInstance().get(SendCommand.TYPE_TEXT, context, true);</code></p>
<p>Notice that the 3rd parameter above is a Boolean. If true, the query returns all commands regardless if their associated applications can be opened; if false, it returns only commands whose associated applications can be opened. Ideally we would set it to false; however, in this post we will see how we can get them all and filter them in our own application logic.</p>
<p>Each SendCommand object has an ID that uniquely identifies the target app and the context. Note that the IDs are not documented as there could be so many of them, but it is fairly easy to figure them out by experimentation. Since our target is the Facebook app and the Twitter app, let me save you the work by telling you what their IDs are.</p>
<p><img class="aligncenter size-full wp-image-9672" title="" src="http://rimdevblog.files.wordpress.com/2012/05/connected-apps-1.jpg?w=550&#038;h=130" alt="" width="550" height="130" /></p>
<p>Now let’s filter:</p>
<p><code>for (int i = 0; i &lt; commandsAll.length; i++) {<br />
if (commandsAll[i].getId().equals("Twitter_text")) {<br />
commands[0] = commandsAll[i];<br />
}<br />
if (commandsAll[i].getId().equals("Facebook_text")) {<br />
commands[1] = commandsAll[i];<br />
}<br />
}</code></p>
<p>&#8230;and we are done. We have our SendCommand objects and we are free to call their run() method anywhere in our app. Be it a Button click or a Menu selection, knock yourself out!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9669/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9669/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9669&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/06/integrate-apps-with-social/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/05/connected-apps-2.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/connected-apps-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/connected-apps-1.jpg" medium="image" />
	</item>
		<item>
		<title>Converting Android Applications to BlackBerry at AnDevCon III</title>
		<link>http://devblog.blackberry.com/2012/05/andevcon-android-blackberry/</link>
		<comments>http://devblog.blackberry.com/2012/05/andevcon-android-blackberry/#comments</comments>
		<pubDate>Thu, 24 May 2012 18:09:37 +0000</pubDate>
		<dc:creator>Veronica O</dc:creator>
				<category><![CDATA[Android Development]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[AnDevCon III]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app porting]]></category>
		<category><![CDATA[BlackBerry development]]></category>
		<category><![CDATA[blackberry playbook]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[porting]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9517</guid>
		<description><![CDATA[BlackBerry evangelists met with Android developers last week at AnDevCon III in Burlingame, CA to talk about the cool development options of bringing Android apps to the BlackBerry platform.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9517&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><img class="aligncenter size-full wp-image-9557" src="http://rimdevblog.files.wordpress.com/2012/05/andevcon_larry_m_talking-to-devs_1.jpg?w=413&#038;h=550" alt="TITLE_IMAGE" width="413" height="550" /></p>
<p>BlackBerry® evangelists met with Android™ developers last week at <a href="http://www.andevcon.com" target="_new">AnDevCon III</a> in Burlingame, CA to talk about the cool development options of <a href="https://bdsc.webapps.blackberry.com/android/" target="_new">bringing Android apps to the BlackBerry platform</a>, and how to publish them on the <a href="http://appworld.blackberry.com" target="_new">BlackBerry App World™</a> storefront to reach a global audience. The word of how easy the process is started to spread out quickly among conference participants at two full-house events on day one of the conference &#8211; the Lightning Talk presented by Larry McDonough, Head of Developer Evangelism Americas at Research In Motion (who talked about bringing existing Android apps to the BlackBerry® PlayBook™ tablet), and at the class taught by Rajeev Mohindra, Director, Handheld App Architecture (about running Android applications on BlackBerry).</p>
<p><span id="more-9517"></span></p>
<p><img class="aligncenter size-full wp-image-9556" title="" src="http://rimdevblog.files.wordpress.com/2012/05/andevcon_larry_m_talking-to-devs_3.jpg?w=413&#038;h=550" alt="" width="413" height="550" /></p>
<p>More BlackBerry development action was happening at the RIM booth, where developers signed up as vendors to BlackBerry App World and learned from BlackBerry experts how to use some of the tools for <a href="http://devblog.blackberry.com/2012/05/runtime-for-android-apps-blackberry-10/" target="_new">BlackBerry Runtime for Android</a> apps to convert their Android “apk” files into BlackBerry-compatible “bar” files. Those developers who completed both these steps became the happy recipients of a free BlackBerry PlayBook tablet on which to continue their development work. That they were all excited to convert their Android apps for the BlackBerry platform is an understatement &#8212; not to mention how pleasantly surprised they were to see how easy it was to make their apps work on the BlackBerry PlayBook tablet without having to change any code. The BlackBerry team saw all kinds of interesting apps &#8211; ranging from games to educational &#8211; all successfully ported to the BlackBerry platform.</p>
<p>To top it all off, a <a href="http://www.blackberry.com/playbook" target="_new">BlackBerry PlayBook</a> tablet was in the mix for the AnDevCon III Winner’s Circle Prize, and was won by Erol Yesin from Navman Wireless. Congratulations to Erol and to all the other developers from whom we are waiting to hear back soon with progress updates.</p>
<p>You can catch up with us again in a couple of weeks, as the <a href="http://www.blackberryjamworldtour.com" target="_new">BlackBerry 10 Jam World Tour</a> will be making a stop in <a href="http://www.blackberryjamworldtour.com/santa-clara" target="_new">Santa Clara, California</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9517/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9517/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9517&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/05/andevcon-android-blackberry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7b375d2578c668cc015d7452d495c9ff?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">veronchiquita</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/andevcon_larry_m_talking-to-devs_1.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/andevcon_larry_m_talking-to-devs_3.jpg" medium="image" />
	</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>
		<item>
		<title>We Jam. We Listen.</title>
		<link>http://devblog.blackberry.com/2012/05/blackberry-10-jam-nobex/</link>
		<comments>http://devblog.blackberry.com/2012/05/blackberry-10-jam-nobex/#comments</comments>
		<pubDate>Tue, 08 May 2012 19:31:58 +0000</pubDate>
		<dc:creator>Alec Saunders</dc:creator>
				<category><![CDATA[Editorials]]></category>
		<category><![CDATA[alec saunders]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 Jam]]></category>
		<category><![CDATA[blackberry app world]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[nobex]]></category>
		<category><![CDATA[nobex radio]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=9359</guid>
		<description><![CDATA[Highlighting a letter from a developer that comments on BlackBerry 10 Jam.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9359&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p style="text-align:center;"><img src="http://rimdevblog.files.wordpress.com/2012/05/alec-saunders-bb10jam.jpg?w=400&#038;h=600" alt="" title="BlackBerry 10 Jam Super Session, Cypress 3" width="400" height="600" class="aligncenter size-full wp-image-9371" /></p>
<p>One of the true pleasures of my job is talking with developers. Creative, outspoken, funny, smart, artistic, genuine – they’re just some of the best people in the world to hang with. <a href="http://www.blackberryjamconference.com/" target="_new">BlackBerry® 10 Jam</a> was amazing last week. The code demos, <a href="http://blackberry10jam.appcircus.com/" target="_new">AppCircus</a>, the lunches and down time with people at the bar – these were the highlights for me.</p>
<p>As you know, I publish my email address everywhere (<a href="mailto:alec.saunders@rim.com">alec.saunders@rim.com</a>), and people write to me. <a href="http://appworld.blackberry.com/webstore/vendor/13/" target="_new">Nobex</a> Chief Software Architect Jamie Julius wrote me the following last Friday, and gave me permission to share it with you all:</p>
<blockquote><p>Hi Alec,</p>
<p>I wanted to thank you personally for such a great BB 10 Jam.</p>
<p>Last November, a letter that I had sent to someone at RIM was forwarded to you. In it I described my feelings after attending DevCon last fall in San Francisco.</p>
<p>Well, things have definitely changed. The difference between that DevCon and this Jam is like night and day.</p>
<p>Over the last three days, in keynotes and in sessions, the messages coming from RIM were very clear. Not only do we now see more clearly where RIM is going, but also what we should be doing as developers. As opposed to a vague range of technologies to be supported, it has now been made more clear which will work best for what.</p>
<p>For Nobex Radio, for example, all the RIM technical representatives made it very clear to me why Cascades is the way for us to go. The list of reasons is long. We never received such a clear message before.</p>
<p>I came away feeling that BB10 is now tangible. And I don&#8217;t just mean that I can hold the Dev Alpha device in my hand. I see real API&#8217;s! Even if some aren&#8217;t ready yet, I see them coming. I know what they will cover. That makes a really big difference. I also have an IDE with which to start writing real code. That makes a big difference too.</p>
<p>Back in November, games were over-emphasized. Not anymore. I think RIM has re-focused its identity. Games should definitely have an important place on BlackBerry smartphones, but not blown out of proportion.</p>
<p>So, a big congratulations to you and your team for doing such a great job putting together BB 10 Jam.</p>
<p>The enormous investment that RIM is making in dev relations has not gone unnoticed.</p>
<p>THANK YOU!</p>
<p>Jamie Julius<br />
Chief Software Architect<br />
Nobex Technologies</p></blockquote>
<p>Thanks Jamie.</p>
<p>There are still lots of milestones to cross on the road to BlackBerry 10, but last week was a major step forward for RIM and the development community. We hope everyone who came to <a href="http://www.blackberryjamconference.com/" target="_new">BlackBerry 10 Jam</a> walked away with the same experience as Jamie, and we’re counting on you all, so let’s go write some code together!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/9359/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/9359/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=9359&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/05/blackberry-10-jam-nobex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6d4fe58df3d76e08b4f82f7df3aa56ea?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">asaund1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/05/alec-saunders-bb10jam.jpg" medium="image">
			<media:title type="html">BlackBerry 10 Jam Super Session, Cypress 3</media:title>
		</media:content>
	</item>
	</channel>
</rss>
