<?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/"
	>

<channel>
	<title>Code Blog</title>
	<atom:link href="http://www.developer.nokia.com/Blogs/Code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.developer.nokia.com/Blogs/Code</link>
	<description>Direct technical comment from Nokia engineers about the latest app development issues</description>
	<lastBuildDate>Fri, 17 May 2013 00:25:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Using the Windows Phone Runtime to mix C++ and C# code</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/05/17/using-the-windows-phone-runtime-to-mix-c-and-c-code/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/05/17/using-the-windows-phone-runtime-to-mix-c-and-c-code/#comments</comments>
		<pubDate>Fri, 17 May 2013 00:25:55 +0000</pubDate>
		<dc:creator>Mansewiz</dc:creator>
				<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1242</guid>
		<description><![CDATA[In Windows Phone 7,  you will typically define your UI in XAML and write the code in C#. If you’re an advanced XAML coder, you might want to harness the power XAML bindings to limit the amount of code you’ll &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/05/17/using-the-windows-phone-runtime-to-mix-c-and-c-code/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In Windows Phone 7,  you will typically define your UI in XAML and write the code in C#. If you’re an advanced XAML coder, you might want to harness the power XAML bindings to limit the amount of code you’ll have to write, and define as much as possible in XAML. If you’re a game developer, you might opt for the XNA framework, in that case you UI will be written from scratch. In any case, regardless of the UI framework you decide to use, your business logic will be coded in C#.</p>
<p>The reason why C# is required comes from the constraint that in WP7, your application is confined run on top of the CLR (Common Language Runtime). The CLR concept is very similar to a Java virtual machine :  the code is converted to an intermediary language that the virtual machine will execute. The CLR environment is commonly called the “managed” mode. The managed mode comes with many great advantages, most notably garbage collection and reflection.  C# is a managed language.</p>
<p>That changed in Windows Phone 8! In addition to the managed framework, developers can write in “native” code. Native code, in comparison with managed code, does not run on top of a virtual machine, but is compiled directly into machine code. As you might expect, native code typically execute slightly faster than managed code. On WP8, native code is written in C or C++.</p>
<p>It is possible to glue pieces of native code with pieces of managed code, thanks to the Windows Phone Runtime framework. The framework takes care of the magic required to convert objects across managed and native runtimes. This <a href="http://www.developer.nokia.com/Community/Wiki/Writing_interfaces_that_can_be_implemented_by_both_Native_and_Managed_classes">Nokia developer wiki</a> gives a quick tutorial how to get started with the Windows Phone Runtime, while this article <a href="http://www.developer.nokia.com/Community/Wiki/C%2B%2B_support_from_Windows_Phone_8">C++ support from Windows Phone 8</a> goes into deeper details.</p>
<p>There are some limitations how one passes objects back and forth between managed and native runtimes, and while the “Windows Phone Runtime Component”  code template shipping with Visual Studio provides all the necessarily plumbing to call a Native object from a Managed object, it may not be that obvious how to call a managed object from a Native object. For example, when a developer needs to call from C++ the functionality only provided by  .NET, like modifying live tiles, send a SMS, &#8230; The same wiki article provides a solution for such a scenario.</p>
<p>Of course, it’s not because you can that you should!  Stick with C#, unless you really need that little extra speed improvement. Or if you have a C++ library that does a great job and just do not want to convert it to C#: that would be such a waste of your time.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/05/17/using-the-windows-phone-runtime-to-mix-c-and-c-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Here + Leap Motion</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/05/16/here-leap-motion/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/05/16/here-leap-motion/#comments</comments>
		<pubDate>Thu, 16 May 2013 15:09:25 +0000</pubDate>
		<dc:creator>simonmadine</dc:creator>
				<category><![CDATA[Location]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1253</guid>
		<description><![CDATA[You might have heard from the tech news outlets about the Leap Motion. If you haven&#8217;t yet, you will soon. It&#8217;s a black box about half the size of an average mouse (computer, not actual) that sits on your desk &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/05/16/here-leap-motion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><img alt="" src="https://dl.dropboxusercontent.com/u/635849/Leap/hereleap.jpg" /></p>
<p>You might have heard from the tech news outlets about the <a href="http://www.leapmotion.com/" target="_blank">Leap Motion</a>. If you haven&#8217;t yet, you will soon. It&#8217;s a black box about half the size of an average mouse (computer, not actual) that sits on your desk and tracks the 3D movement of your hand (actual, not computer). Essentially, it&#8217;s like an XBox Kinect but instead of tracking limb movements, it tracks fingers. These devices are being released mid-July but the <a href="http://here.com" target="_blank">here.com</a> team were lucky enough to get into the developer preview program so that we could integrate the Leap with <a href="http://here.com" target="_blank">here.com</a>.<br />
<span id="more-1253"></span></p>
<p>(A quick aside: it&#8217;s pretty cool that we get to play with cool toys like this as our actual job. You should totally think about <a href="http://www.nokia.com/global/about-nokia/careers-page/" target="_blank">joining our team</a>.)</p>
<h2>3D and the Web</h2>
<p>All the finger tracking and so on would be pretty impressive on its own but the developers of the Leap have made it extremely versatile by providing a <a href="https://github.com/leapmotion/leapjs" target="_blank">JavaScript library</a> to allow you to integrate it into a web app. So we did exactly that. The Leap driver sits in the background on your computer relaying the data from the device to a <a href="https://developer.mozilla.org/en/docs/WebSockets" target="_blank">WebSocket</a>. Web sites and applications can check for the existence of this WebSocket and, if they find it open and active, listen to a stream of JSON objects coming out of it. In essence, you move your hand above the Leap and your web app gets told there&#8217;s a hand moving around, how many fingers it has, where the fingers are, what direction they&#8217;re pointing and so on.</p>
<h2>Enough Talk, show me!</h2>
<p>If you&#8217;ve got a Leap, read this far and just want the demo, go to <a href="http://here.com/leap" target="_blank">here.com/leap</a>. If you haven&#8217;t got one yet, this video should explain what we did:</p>
<p><iframe width="584" height="329" src="http://www.youtube.com/embed/h5CYeESsTko?feature=oembed" frameborder="0" allowfullscreen></iframe></p>
<p>Note: WebGL isn&#8217;t supported across all browsers yet. If you don&#8217;t have a WebGL-enabled browser, there&#8217;s still the rest of <a href="http://here.com" target="_blank">here.com</a> to explore.</p>
<h2>Challenges</h2>
<p>Leap-enabled applications are very CPU-intensive. The device collects a big amount of sensor data that is streamed through the USB port to a <em>Leap Motion Controller</em> application that does some computation and sends the parsed data to applications via WebSocket. All of this is a lot of work for the CPU, which means that soon enough, even on a high-end laptop or desktop computer fans start spinning quite fast. The Leap sensor itself becomes pretty hot after using it for a while.</p>
<p>We added WebGL to the mix, so our users can use the Leap to control a paper airplane and fly around the buildings of the coolest cities in the world. This is an additional element that keeps the CPU busy, but the experience is still nice and smooth with 3D maps rendered at 60FPS.</p>
<h2>Gestures are hard</h2>
<p>There are numerous native libraries available to help process gestures but translating this to an entirely web-based application is not easy. Gesture detection can be computationally heavy and, as mentioned above, we&#8217;re already pushing the computer quite hard. We prototyped with the <a href="http://depts.washington.edu/aimgroup/proj/dollar/" target="_blank">$1 gesture library</a> but in the end, removed gesture recognition from our demo.</p>
<h2>No established patterns</h2>
<p>The biggest thing we discovered that might not be obvious at first was not strictly a technical one. There are very few examples of 3D interactions. This is a new paradigm of computer interfaces and we struggled to get something that was familiar enough to be intuitive but accurate enough to not be unforgiving. Most of our early attempts involved introducing an arbitrary constraint to the &#8216;gesture space&#8217;. The most successful was probably the &#8216;virtual screen&#8217; which registers movements as being &#8216;active&#8217; if they are within a small z-distance from the device. In essence, it reduces the space in which user interactions are detected to an invisible screen parallel to the leap. By doing this, you get to fallback to typical touch gestures &#8211; pan, pinch-zoom &#8211; with the benefit of also having a hover state when the user&#8217;s fingers are detectable but not &#8216;touching&#8217; the virtual screen.</p>
<p>The most successful interaction is the one we eventually ended up going with &#8211; direct control. To take most advantage of the hand-tracking, we decided to simply map the movements of the user&#8217;s hand to the position and angle of the airplane. This not only simpified things but also had the effect of being intuitive. The user can quickly learn that what they do is represented on screen.</p>
<p>On a technical level, this was much easier to accomplish than gesture-based control as we now take the information about the hand position coming from the Leap and pass it directly through to the position of the 3D camera in the WebGL world.</p>
<p>What do you think? Is this the future of computer interaction or just a great way to explore <a href="http://here.com/3d" target="_blank">HERE 3D</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/05/16/here-leap-motion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What’s new in the Nokia Asha UI?</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/05/13/whats-new-in-the-nokia-asha-ui/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/05/13/whats-new-in-the-nokia-asha-ui/#comments</comments>
		<pubDate>Mon, 13 May 2013 20:45:28 +0000</pubDate>
		<dc:creator>SannaH</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Touch UI]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1270</guid>
		<description><![CDATA[The visual look and feel of Nokia Asha UI is very different from the previous Series 40 UI’s. Luckily, most of the API’s remained the same! One major API change that affects the UI and UX has been done for &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/05/13/whats-new-in-the-nokia-asha-ui/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The visual look and feel of Nokia Asha UI is very different from the previous Series 40 UI’s. Luckily, <a href="https://www.developer.nokia.com/Resources/Library/Java/#!porting-guides/porting-midlets-to-the-nokia-asha-software-platform/jsrs-and-apis.html" target="_blank">most of the API’s remained the same</a>!</p>
<p><span id="more-1270"></span></p>
<p>One major API change that affects the UI and UX has been done for the <a href="https://www.developer.nokia.com/Resources/Library/Java/#!developers-guides/ui-graphics-and-interaction/high-level-ui-components/categorybar.html;#toc_DifferencesbetweenSeries40fulltouchandNokiaAshasoftwareplatform10" target="_blank">CategoryBar API</a>; it now supports two different modes. You can use it as a tab bar (like it has been used for Full touch), and in addition as a toolbar for the most frequently used actions. At the same time the CategoryBar extension has been disabled for Nokia Asha UI. There is a fixed number of four items you can place in the Category bar, both in portrait and in landscape.</p>
<p><a href="http://www.developer.nokia.com/Blogs/Code/files/2013/05/ui_example.png"><img class="alignnone size-medium wp-image-1280" alt="new asha ui" src="http://www.developer.nokia.com/Blogs/Code/files/2013/05/ui_example-300x194.png" width="300" height="194" /></a></p>
<p>You probably remember <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/" target="_blank">my blog post from a while back</a>, where I discussed this same issue but saying that actions are not allowed in the CategoryBar? Well, that still holds for the Full touch; the API change doesn’t apply there. So, when you are bringing your Full touch MIDlet to Nokia Asha and you have “played by the rules” (i.e. not having actions in your CategoryBar), you only need to consider the amount of tabs you have (only 4 possible with Nokia Asha UI, compared to 15 with Full touch).</p>
<p>But if you decide to create a new MIDlet for Asha and use actions in the CategoryBar, you will need to have another solution for Full touch, due to the facts described in <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/" target="_blank">my old post</a>.</p>
<p>It’s also important to keep in mind that tabs and actions cannot be mixed in the same CategoryBar. This also comes back to the visualization of the component. So either use tabs (one item is always selected, used for changing the view) or actions (none of the items is in selected mode, used to trigger an action).</p>
<p>See the <a href="http://www.developer.nokia.com/Resources/Library/Asha_UI/#!index.html" target="_blank">Nokia Asha design guidelines</a> if you haven’t already!</p>
<p>Happy developing,<br />
Sanna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/05/13/whats-new-in-the-nokia-asha-ui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hot stuff: Nokia Asha design guidelines!</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/05/13/hot-stuff-nokia-asha-design-guidelines/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/05/13/hot-stuff-nokia-asha-design-guidelines/#comments</comments>
		<pubDate>Mon, 13 May 2013 16:50:18 +0000</pubDate>
		<dc:creator>SannaH</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Touch UI]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1224</guid>
		<description><![CDATA[Want to know how the Asha UI looks like and read the UX documentation? Well, aren&#8217;t you lucky: here&#8217;s the link! The Nokia Asha design guidelines provide a comprehensive set of UI component descriptions and UI patterns. For app icons, &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/05/13/hot-stuff-nokia-asha-design-guidelines/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Want to know how the Asha UI looks like and read the UX documentation? Well, aren&#8217;t you lucky: <a href="http://www.developer.nokia.com/Resources/Library/Asha_UI/#!index.html" target="_blank">here&#8217;s the link</a>!</p>
<p><a href="http://www.developer.nokia.com/Resources/Library/Asha_UI/#!index.html" target="_blank">The Nokia Asha design guidelines</a> provide a comprehensive set of UI component descriptions and UI patterns. For app icons, templates and guidelines are of course included. And to make things as simple as they can get, there&#8217;s also a UX checklist.</p>
<p>Stay tuned for more updates on the Asha UI in this blog. And don&#8217;t forget to check the <a href="https://www.developer.nokia.com/News_and_events/" target="_blank">Event calendar</a> for Asha UI webinars!</p>
<p>Happy developing,<br />
Sanna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/05/13/hot-stuff-nokia-asha-design-guidelines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Asha Web Apps with Brunch and Jade</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/05/07/creating-asha-web-apps-with-brunch-and-jade/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/05/07/creating-asha-web-apps-with-brunch-and-jade/#comments</comments>
		<pubDate>Tue, 07 May 2013 15:54:47 +0000</pubDate>
		<dc:creator>vivainio</dc:creator>
				<category><![CDATA[Series 40]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Apps]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1186</guid>
		<description><![CDATA[Asha web apps? Asha web apps are a lightweight application development framework for creating apps for low end Nokia devices (Asha series and earlier). While JME is the most popular technology for creating apps for Asha, web apps are a &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/05/07/creating-asha-web-apps-with-brunch-and-jade/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h2>Asha web apps?</h2>
<p>Asha web apps are a lightweight application development framework for creating apps for low end Nokia devices (Asha series and earlier). While JME is the most popular technology for creating apps for Asha, web apps are a reasonably quick and convenient way to expose content on the web &#8211; basically, your garden variety front ends for restful services, spiced by some simple navigation.</p>
<p>Since Asha devices don&#8217;t have local javascript execution, javascript is executed on proxy server. &#8220;Normal&#8221; web pages execute all javascript on the proxy, but Asha web apps provide some &#8220;shortcuts&#8221; for doing simple DOM manipulation (add/remove css classes, set values in input fields) without the proxy roundtrip. Check out &#8220;MWL&#8221; library for details.</p>
<h2>Standard workflow</h2>
<p>Normally, you use Eclipse to develop and test Asha web apps. Nokia provides the &#8220;Nokia Web Tools&#8221; IDE for this; it&#8217;s a rather mainstream Eclipse based IDE, spiced with webkit based &#8220;local&#8221; simulator (that runs javascript locally), and the &#8220;cloud&#8221; simulator that runs Javacript on the real Nokia proxy servers (but still renders the DOM on the webkit based simulator).</p>
<p>While this is fine for most web developers, there are lots of us relentlessly looking to optimize our workflows, to make it little more efficient, little more fun (or more tolerable, depending how bad an aversion you have for Javascript and HTML) and little more readable and maintainable.</p>
<p>For this kind of developer, there are tools like CoffeeScript, Brunch, Jade, SASS, LESS, HAML. In this exposition we&#8217;ll use CoffeeScript, Brunch and Jade.</p>
<p><strong>CoffeeScript</strong> is a language that compiles to idiomatic and readable/debuggable JavaScript. It makes producing JavaScript more tolerable for people used to modern languages without semicolons, `function` keywords<br />
and a selection of other nastiness that plagues JavaScript.</p>
<p><strong>JADE</strong> is a language that compiles to HTML.</p>
<p>This Jade:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="jade" style="font-family:monospace;">        doctype 5
	html(lang=&quot;en&quot;)
	  head
	    title= pageTitle
	  body
	    h1 Jade - node template engine
	    #container
	      if youAreUsingJade
	        p You are amazing
	      else
	        p Get on it!</pre></td></tr></table></div>

<p>Compiles to this html:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>Jade - node template engine<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;container&quot;</span>&gt;</span>
&nbsp;
You are amazing
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<p>As you can see, this makes it easier to &#8220;see forest from the trees&#8221;, as the eye is not misdirected by stream of redundant characters and endless &lt;div&gt;&#8217;s.</p>
<p><strong>Brunch</strong> is an &#8220;assembler&#8221; for HTML5 applications. It picks up all the pieces you have (CoffeeScript files, JADE templates, etc.) and produces a runnable web application out of that. It can watch the files on the background, compiling CoffeeScript files to JavaScript the second you save them, running unit tests immediately, refreshing the browser in real time etc.</p>
<p>We use Brunch as the &#8220;skeleton&#8221; of our Asha web application.</p>
<h2>Getting started</h2>
<p>Prerequisites: This flow has been tested on Linux and Windows. Have to install Node.js, git, the usual stuff every self respecting web developer has set up on day one. Anecdotal evidence suggests it&#8217;s a good idea to compile Node.js from source instead of using the packaged versions, if you are lucky enough to be on Linux.</p>
<p>We clone the basic scaffolding from github and install the dependencies:</p>
<p>&nbsp;</p>
<p>$ git clone git@github.com:vivainio/awa-brunch.git awa-helloworld<br />
$ cd awa-helloworld/<br />
$ npm install<br />
npm http GET https://registry.npmjs.org/javascript-brunch<br />
npm http GET https://registry.npmjs.org/css-brunch<br />
npm http GET https://registry.npmjs.org/uglify-js-brunch<br />
npm http GET https://registry.npmjs.org/clean-css-brunc<br />
.. etc ..<br />
This install Brunch, CoffeeScript compile and lots of other packages with npm.</p>
<p>Let&#8217;s take a look at the project structure:</p>
<p><code><br />
ville@ville-tp:~/p/awa-helloworld$ tree app<br />
app<br />
├── assets<br />
│   ├── config.xml<br />
│   ├── icon.png<br />
│   ├── index.html<br />
│   └── s40-theme<br />
│   ├── css<br />
│   │   ├── s40-theme.css<br />
│   │   ├── single_landscape.css<br />
│   │   └── single_portrait.css<br />
│   ├── images<br />
│   │   ├── arrow-close.png<br />
│   │   ├── arrow-open.png<br />
│   │   ├── back_40x40.png<br />
│   │   ├── button-bg_40x40.png<br />
│   │   ├── close_40x40.png<br />
│   │   ├── grid_40x40.png<br />
│   │   ├── option-menu_titlebar.png<br />
│   │   ├── refresh_40x40.png<br />
│   │   ├── search_40x40.png<br />
│   │   ├── tab_bg.png<br />
│   │   └── title-bar.png<br />
│   └── js<br />
│   ├── s40-theme.js<br />
│   └── screensize.js<br />
├── index.jade<br />
├── README.md<br />
├── templates<br />
│   └── mainlist.jade<br />
├── testCs.coffee<br />
└── testJs.js</code></p>
<p>&nbsp;</p>
<p>Now, we start &#8220;brunch watch&#8221; that compiles the application in real time as we edit the files, and for added convenience launches a webserver serving on :3333:</p>
<p><code><br />
ville@ville-tp:~/p/awa-helloworld$ brunch watch --server<br />
26 Apr 22:03:48 - info: application started on http://localhost:3333/<br />
26 Apr 22:03:48 - info: compiled in 115ms<br />
26 Apr 22:03:49 - info: compiled in 206ms</code></p>
<p>&nbsp;</p>
<p>The resulting application that we can deploy, or preview in browser, gets generated in awa-helloworld/public directory:</p>
<p>&nbsp;</p>
<p>ville@ville-tp:~/p/awa-helloworld$ tree public<br />
public<br />
├── config.xml<br />
├── icon.png<br />
├── index.html<br />
├── javascripts<br />
│   ├── app.js<br />
│   ├── templates.js<br />
│   └── vendor.js<br />
├── js<br />
│   └── templates.js<br />
└── s40-theme<br />
├── css<br />
│   ├── s40-theme.css<br />
│   ├── single_landscape.css<br />
│   └── single_portrait.css<br />
├── images<br />
│   ├── arrow-close.png<br />
│   ├── arrow-open.png<br />
│   ├── back_40x40.png<br />
│   ├── button-bg_40x40.png<br />
│   ├── close_40x40.png<br />
│   ├── grid_40x40.png<br />
│   ├── option-menu_titlebar.png<br />
│   ├── refresh_40x40.png<br />
│   ├── search_40x40.png<br />
│   ├── tab_bg.png<br />
│   └── title-bar.png<br />
└── js<br />
├── s40-theme.js<br />
└── screensize.js</p>
<p>&nbsp;</p>
<p>&#8220;Sources&#8221; under app/ directory were processed to produce these files; .coffee files were compiled and concatenated to &#8220;app.js&#8221;, index.jade was converted to index.html, and so on.</p>
<p>There is one extra directory we didn&#8217;t show yet, the &#8220;vendor&#8221; directory:</p>
<p><code><br />
ville@ville-tp:~/p/awa-helloworld$ tree vendor/<br />
vendor/<br />
├── jade_runtime.js<br />
└── README.md<br />
</code></p>
<p>If you are using JavaScript libraries like jQuery, you would just copy it under vendor/ and all of them get automatically concatenated to vendor.js. This makes the app fast to load as it reduces the amount of separate files to download. For production, Brunch can also minify the Javascript files to further reduce page weight. jade_runtime.js is here to support *precompiled Jade templates*</p>
<h2>Shut up and show it running</h2>
<p>In the interest of making things as &#8220;familiar&#8221; and frictionless as possible, we will preview the application in standard Chrome browser instead of Nokia Web Tools. So we launch Chromium and disable web security to prevent CORS from cramping our style and killing our Ajax requests:</p>
<pre>	$ chromium-browser --disable-web-security http://localhost:3333</pre>
<p>This doesn&#8217;t look at all what you would expect on the phone screen, because we haven&#8217;t specified a viewport size:</p>
<p><img alt="" src="http://vivainio.github.io/static/images/awa_chrome_raw.png" /></p>
<p>Chromium inspector has a handy feature of overriding the viewport size (Settings -&gt; Overrides -&gt; Device Metrics), so we use it to set the resolution to match Asha Full Touch devices (240 x 400):</p>
<p><img alt="" src="http://vivainio.github.io/static/images/awa_chrome_device_metrics.png" /></p>
<p>Now, we have a low-fidelity representation of the phone experience! While this certainly wouldn&#8217;t satisfy an UI designer, it&#8217;s sufficient for a busy software developer that mostly needs to focus on the &#8220;logic&#8221; side of the web app.</p>
<h2>Launching in NWT</h2>
<p>Now is the time to get this running with &#8220;real&#8221; IDE, i.e. Nokia Web Tools. Launch NWT, do File -&gt; New -&gt; Import web app, select public/config.xml and launch the application in local preview:</p>
<p><img alt="" src="http://vivainio.github.io/static/images/awa_nwt_1.png" /></p>
<h2>Is this it?</h2>
<p>There is more to show: how to utilize precompiled templates, how to inject the MWL library, and how Jade can help you create MWL UI &#8220;components&#8221; with reusable, encapsulated logic. These, and other things to smoothen the development flow will be covered in another blog post, as this already got way too long.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/05/07/creating-asha-web-apps-with-brunch-and-jade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I want my actions!</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/#comments</comments>
		<pubDate>Tue, 30 Apr 2013 16:57:40 +0000</pubDate>
		<dc:creator>SannaH</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Touch UI]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1105</guid>
		<description><![CDATA[The Nokia Asha full touch offering introduced an API called Category bar. In the UX guidelines it says that you should never, ever, in a million years place actions in there. Now why is that? Are we just trying to &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The Nokia Asha full touch offering introduced an API called Category bar. In the <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!ui-components/category-bar.html" target="_blank">UX guidelines</a> it says that you should never, ever, in a million years place actions in there. Now why is that? Are we just trying to fool you with this guidance? No, we’re not. And this is why.</p>
<p><span id="more-1105"></span></p>
<p>The Category bar uses permanent highlight for the currently selected category—one of the category icon buttons is always in the pressed-down state (Pro tip: See the <a href="https://projects.developer.nokia.com/s40uivisualisation" target="_blank">Series 40 UI component demos</a> to see how it&#8217;s done on the code side!). Let’s assume that we have placed an action there; if your user wants to trigger the same action twice in a row, how would that be possible when the button is pressed down after the first go? The answer is: there would be no way.</p>
<p>So even though it’s technically possible to place actions in the Category bar, you really shouldn&#8217;t do that because your app will become more or less unusable at that point.</p>
<p><img class="alignnone size-medium wp-image-1143" alt="category bar more" src="http://www.developer.nokia.com/Blogs/Code/files/2013/04/catbar_more-180x300.png" width="180" height="300" /></p>
<p>Now that we agree that actions do not belong to the Category bar and that it is a <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!ui-patterns/view-navigation.html" target="_blank">navigation element</a> (used for changing the view), let’s go through another burning issue: Category bar should remain level contextual.</p>
<p>Parallel view navigation basically means that all the views are on the same hierarchy level; you don’t drill down when you change the category. Since Back is following hierarchy (not history), this also means that with simple tab navigation the Back will exit the MIDlet (and not change to the previously visited category).</p>
<p>If you combine drill down functionality to either of your category views, you shouldn’t show the Category bar anymore when drilling down. If you did, what would happen when the user taps &#8220;Back&#8221;? Would they exit the app or move to the main level of the drilled down view? Would you change the backstepping paradigm to make it historical? The user wouldn&#8217;t know what to expect anymore.</p>
<p>Because of this conflict you never should show the main Category bar on any drill-down view.</p>
<p><img class="alignnone size-medium wp-image-1145" alt="category selection plus" src="http://www.developer.nokia.com/Blogs/Code/files/2013/04/category_selection_plus_-300x165.png" width="300" height="165" /></p>
<p>To summarise the main things for the Category bar, here’s a recap from the <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!ux-checklist.html" target="_blank">Full touch UX checklist</a>:</p>
<ul>
<li>Categories are used to provide visibility and navigation between different sub-apps, functionalities, or modes within an app.</li>
<li>The functionality of the Category bar can be compared to tabs.</li>
<li>The Category bar is level contextual, i.e. you should not show it when user drills down in hierarchy.</li>
<li>The Category bar is not used for representing actions.</li>
<li>The currently active category is highlighted.</li>
<li>If there are more categories than what fits to the Category bar, the categories are accessible via the Category bar extension.</li>
<li>The Category bar extension icon (three dots) is exclusively used for opening the extension view. Do not use the icon for any other category (or action in Action button 1).</li>
<li>Back is part of the Category bar, positioned at the rightmost location.</li>
</ul>
<p>Happy developing,<br />
Sanna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/04/30/i-want-my-actions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Make it big – why size matters.</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/04/22/make-it-big-why-size-matters/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/04/22/make-it-big-why-size-matters/#comments</comments>
		<pubDate>Mon, 22 Apr 2013 17:29:08 +0000</pubDate>
		<dc:creator>SannaH</dc:creator>
				<category><![CDATA[Touch UI]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[User Experience]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1070</guid>
		<description><![CDATA[Nowadays everything seems to be getting smaller; SIM cards, computers, prices for TVs, transistors, pixel sizes of video screens. So, why not also reduce the size of a font or icon to get more information into your app? Small graphics &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/22/make-it-big-why-size-matters/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Nowadays everything seems to be getting smaller; SIM cards, computers, prices for TVs, transistors, pixel sizes of video screens. So, why not also reduce the size of a font or icon to get more information into your app? Small graphics look sharp and crisp on small displays with very low pixel sizes. It&#8217;s very tempting.</p>
<p>The answer is simple: We are now getting to a saturation point—actually we have been there for a while. In this context, saturation means that relevant UI components will not benefit from higher resolution.</p>
<p><span id="more-1070"></span></p>
<p>Take the case of fonts. There is a minimum font size which people can read conveniently without glasses at a certain age (see <a href="http://blog.joshherigon.com/post/12370199164/guy-kawasakis-formula-for-minimum-font-size-in-a" target="_blank">Guy Kawasaki’s formula for minimum font size in a presentation</a>). The issue isn&#8217;t limited to fonts, however.</p>
<p>It&#8217;s important to be aware of a big trap in developing for mobile. You are not developing for people using a 30 inch display, but for people using a 3 inch display. As a rule of thumb, today the pixels on your computer screen are roughly double the size they are on your mobile phone screen. The font you are seeing from the emulator has twice the size you see on the actual phone. Maybe you have enlarged the output of your emulator, say double. So you see the font four times larger than what your user would see on-device.</p>
<p>Pro tip: Test your app on a real phone!</p>
<p>Let’s continue the thought from a different point of view. You are sitting in a comfortable chair. Your light is not flickering. Your computer is not moving anywhere or shaking because it is not installed in a bus which is driving on a bumpy road. If there is direct sunlight on your computer screen you can block the sun out by either closing the blinds or turning the screen. You do not have to do initial readings from a new screen all the time because you sit in front of the screen for a longer period and you know the screen.</p>
<p>In addition, people grow older and in many cases their eyesight gets worse. Double the age, double the font size!</p>
<p>Don&#8217;t forget to consider eye-finger coordination of people using a touch-enabled phone. At the computer you use a mouse on a target 16 times larger than on a phone, with a pointer device of 10th of a millimeter (or better) precision. Your user in the wild, commuting with a phone and your application has only one hand free (the other hand is used for securing herself), and she can probably only use her thumb with a precision of a bit better than a centimeter. Even worse, the actual press down point is a bit lower than the perceived center of the finger tip due to parallax.</p>
<p>Put it this way; while developing, you have plenty of unfair advantages over your user and you must be aware of that.</p>
<p>Now that you are aware of your advantages, what should you do? For full touch phones, keep in mind the following guidelines:</p>
<ul>
<li>The minimum font size should be not less than 14 pt</li>
<li>No side of a touch area should be less than 7 mm (43 pixels in full touch) for finger use</li>
<li>For thumb use (in the case of one handed use) no side should be less than 9 mm (55 pixels in full touch)</li>
<li>Include margins of 1 mm (6 pixels in full touch) between all touch areas</li>
<li><a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!icon-creation.html" target="_blank">Use icons large enough for its purpose</a>.</li>
<li><a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!ux-checklist.html">Further information can be found in the UX checklist</a>.</li>
</ul>
<p>This all means that you cannot fit endless amounts of content on a phone screen and especially on phones with smaller screens (3 inches or smaller). This will be a real challenge for you, but not impossible.</p>
<p>A final piece of advice: Test—on a real phone and with a real user. Take your mom on the shakiest bus ride you have in town and make her operate your app.</p>
<p>With these few considerations, you can help ensure that your app will be accessible for most of your users and even better, they will thank you (at least subconsciously) for paying attention to their needs.</p>
<p>Happy developing!</p>
<p>Sanna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/04/22/make-it-big-why-size-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to detect if NFC is enabled on Windows Phone 8 devices</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/04/16/how-to-detect-if-nfc-is-enabled-on-windows-phone-8-devices/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/04/16/how-to-detect-if-nfc-is-enabled-on-windows-phone-8-devices/#comments</comments>
		<pubDate>Tue, 16 Apr 2013 17:02:45 +0000</pubDate>
		<dc:creator>wenlu</dc:creator>
				<category><![CDATA[NFC]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1012</guid>
		<description><![CDATA[Near field communication (NFC) enables many practical features by using the intuitive tapping gestures, such as sharing contacts, pairing Bluetooth, sending photos, etc. The Proximity API, as the enabler of NFC on Windows Phone 8,  has gained a lot of &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/16/how-to-detect-if-nfc-is-enabled-on-windows-phone-8-devices/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Near field communication (NFC) enables many practical features by using the intuitive tapping gestures, such as sharing contacts, pairing Bluetooth, sending photos, etc. The Proximity API, as the enabler of NFC on Windows Phone 8,  has gained a lot of attention from application developers.</p>
<p><span id="more-1012"></span></p>
<p>From a developer point of view, detecting if NFC is enabled or not is usually the first step  before using the proximity API to perform NFC-enabled features. There are two steps to check in order to sort out all the scenarios:</p>
<ol>
<li>Check if there are any proximity devices installed on the device.</li>
<li>Check if “Tap+Send” setting is switched on or off. The UI for this setting is illustrated below.</li>
</ol>
<p><a href="http://www.developer.nokia.com/Blogs/Code/files/2013/04/tap_send_setting_ui.png"><img class="alignnone size-medium wp-image-1022" alt="Tap and send UI" src="http://www.developer.nokia.com/Blogs/Code/files/2013/04/tap_send_setting_ui-180x300.png" width="180" height="300" /></a></p>
<p>In order to check if there are any proximity devices installed, the developers has two options:</p>
<ul>
<li>Option 1:  Add ID_REQ_NFC as a HW requirement for the application.</li>
<li>Option 2:  Use the following code to figure it out:</li>
</ul>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">var</span> proximityDevice <span style="color: #008000;">=</span> Windows<span style="color: #008000;">.</span><span style="color: #0000FF;">Networking</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Proximity</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ProximityDevice</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetDefault</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>proximityDevice <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// at least one proximity device installed</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #0600FF; font-weight: bold;">else</span> <span style="color: #008000;">&#123;</span>
   <span style="color: #008080; font-style: italic;">// no proximity device installed</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>&nbsp;<br />
Using the ID_REQ_NFC will hide the application from the app store for the customer if his or her device does not have a NFC chip. However, sometimes NFC is not necessarily the key feature of the application. Therefore, option 2 might be more practical to determine whether to provide NFC related features in the application or not.</p>
<p>Currently (Apr 2013) there is no public API on WP8 for third-party developers to check if “Tap+Send” is switched on or off. If the setting is switched off, Proximity API will behave as if it is working properly without exceptions, but both publish and subscribe requests will be ignored without notification. This could cause your customers confusion.</p>
<p>As currently there is no public SDK to check “Tap+Send” setting, developers have to remind customers to switch on “Tap+Send” setting no matter whether it is currently switched on or off. Also unlike other settings e.g. wifi or bluetooth, “tap+send” does not have yet a <a href="http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj662937(v=vs.105).aspx" target="_blank">public URI schemes from MSDN</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/04/16/how-to-detect-if-nfc-is-enabled-on-windows-phone-8-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Style guide &#8211; I don&#8217;t need this, do I?</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/04/15/style-guide-i-dont-need-this-do-i/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/04/15/style-guide-i-dont-need-this-do-i/#comments</comments>
		<pubDate>Mon, 15 Apr 2013 18:12:59 +0000</pubDate>
		<dc:creator>SannaH</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Touch UI]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[User Experience]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=1030</guid>
		<description><![CDATA[No of course you don&#8217;t need a style guide. But people who are using your application desperately need you to need one. You know, the people who create the revenue for your application, either with ads or by paying for &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/15/style-guide-i-dont-need-this-do-i/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>No of course you don&#8217;t need a style guide. But people who are using your application desperately need you to need one. You know, the people who create the revenue for your application, either with ads or by paying for the application&#8230;</p>
<p><span id="more-1030"></span></p>
<p>There are few extremely good reasons to follow a platform style guide::</p>
<ul>
<li>People will immediately know how to use the basic functionality and they feel kind of &#8220;home&#8221; right away.</li>
<li>They will make fewer mistakes.</li>
<li>The app will look and feel like an integral part of the phone, something that belongs there.</li>
<li>People will perceive that you have taken care about your customers, i.e. your users.</li>
</ul>
<p>(Psst&#8230; You can find the style guides for <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!index.html" target="_blank">Series 40 full touch</a>, <a href="http://www.developer.nokia.com/info/sw.nokia.com/id/d7390258-7212-48ef-ae7b-54cbcc4ca2a1/Series_40_Touch_Type_UI_Style_Guide_v1_0_en.pdf.html" target="_blank">Series 40 touch and type</a>, <a href="http://www.developer.nokia.com/Resources/Library/Series_40_Non-touch_Design/" target="_blank">Series 40 non-touch</a>, and <a href="http://dev.windowsphone.com/en-us/design/library" target="_blank">Windows Phone 8</a> online!)</p>
<p>You can also look at this the other way around. Say you do not follow the style guide, but just do a direct port e.g. from an application optimised for a non-Series 40 phone to a Series 40 phone. It is very likely that:</p>
<ul>
<li>People won&#8217;t know at first how to navigate your app since the main UI elements are not where they would expect them to be. They will be confused even before they started exploring your app! This is a not a good start for trying out something new.</li>
<li>People will make a lot of mistakes. A simple example: For a Series 40 full-touch application, say you place the Options menu bottom right and the back button top left. Since the application is used by Series 40 users, they will open the Options menu every time they want to step back, since all the other applications in the phone work this way. Even if the rest of your app works flawlessly, people might easily give you bad ratings, just because of this one flaw.</li>
<li>It really doesn&#8217;t help if your app is getting nice reviews for the &#8220;non-Series 40 app&#8221;; in this example, the users of full-touch phones are not used to the UI style of that &#8220;non-Series 40 platform&#8221;.</li>
<li>The application might not render correctly and might look broken.</li>
<li>People might get the impression that you just want to make money and don&#8217;t care about your customers!</li>
</ul>
<p>Especially for mobile applications (no matter for which platform), it is very important that your application is re-designed and optimised according to the style guide of the platform or even according to the edition of the platform. This has been proven in several large studies. (For some examples, see <a href="http://www.nngroup.com/" target="_blank">Jacob Nielsen&#8217;s</a> site.)</p>
<p>It also means:</p>
<ul>
<li>There is no universal style guide to cover all mobile phone platforms.</li>
<li>There is no universal answer about where to place common UI components, e.g. &#8220;Do I put YES or NO on the left button of a query&#8221;. This depends entirely on the platform you are targeting.</li>
</ul>
<p>If your app is getting bad ratings:</p>
<ul>
<li>Read the users&#8217; comments and try to fix what is wrong.</li>
<li>Have a look into our <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!ux-checklist.html" target="_blank">UX checklist</a>. Following it often helps fix the most common flaws.</li>
<li>Check the UX webinars online; we have listed some in the <a href="http://www.developer.nokia.com/Resources/Library/Full_Touch/#!index.html" target="_blank">Full touch library</a>.</li>
<li>Check the <a href="https://www.developer.nokia.com/News_and_events/" target="_blank">Event calendar</a> for our UI Clinic webinars and submit your app; we can then figure out together how to improve your app.</li>
</ul>
<p>For more information on our design resources:</p>
<ul>
<li><a href="http://www.developer.nokia.com/Resources/Library/Design_and_UX/#!designing-for-series-40.html" target="_blank">Designing for Series 40</a></li>
<li><a href="http://www.developer.nokia.com/Resources/Library/Design_and_UX/#!designing-for-windows-phone.html" target="_blank">Designing for Windows Phone</a></li>
</ul>
<p>Oh, and one final thought: We are talking about a style guide, not a style law. Don&#8217;t forget to have fun. <img src='http://www.developer.nokia.com/Blogs/Code/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Happy developing,<br />
Sanna</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/04/15/style-guide-i-dont-need-this-do-i/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Use the PeerFinder API to launch applications via NFC</title>
		<link>http://www.developer.nokia.com/Blogs/Code/2013/04/08/use-the-peerfinder-api-to-launch-applications-via-nfc/</link>
		<comments>http://www.developer.nokia.com/Blogs/Code/2013/04/08/use-the-peerfinder-api-to-launch-applications-via-nfc/#comments</comments>
		<pubDate>Mon, 08 Apr 2013 16:38:51 +0000</pubDate>
		<dc:creator>wenlu</dc:creator>
				<category><![CDATA[Connectivity]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[NFC]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Windows Phone]]></category>

		<guid isPermaLink="false">http://www.developer.nokia.com/Blogs/Code/?p=856</guid>
		<description><![CDATA[With the introduction of NFC on Windows Phone 8, the scenarios of device interaction become much more reachable to consumers and developers. By simply by tapping one WP8 device with another, we can perform a variety of tasks, like sharing &#8230; <a href="http://www.developer.nokia.com/Blogs/Code/2013/04/08/use-the-peerfinder-api-to-launch-applications-via-nfc/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>With the introduction of NFC on Windows Phone 8, the scenarios of device interaction become much more reachable to consumers and developers. By simply by tapping one WP8 device with another, we can perform a variety of tasks, like sharing a contact, photo, video, or app, pairing with Bluetooth, etc.</p>
<p>The Proximity API in WP8 provides two main classes for NFC related features: ProximityDevice and PeerFinder. ProximityDevice enables functionality like publish/subscribe for NFC messages to and from tags or another devices, while PeerFinder focuses on pairing two devices with a socket connection using NFC tapping or browsing without NFC involvement.</p>
<p>Launching an application from another device is one of the most important features that NFC provides. In most cases, launching the same application from another device is desired to enable further interactions on the same app context between two devices, such as multi-player games, messaging apps, media sharing, etc. Both ProximityDevice and PeerFinder can perform this task.</p>
<p>By using ProximityDevice, developers need to make a URI association for the app and then publish the custom URI to another device. This approach enables the app to interact with other applications as well. However, sometimes app developers do not want to disclose the interface to others due to confidentiality. In such cases, the URI association might not be the best option.</p>
<p>On the other hand, many developers have encountered issues where if both apps are running in the foreground on separate devices and either Fast App Resume (FAR) or BackgroundExecution is defined in the manifest, then passing the URI through NFC will not trigger the MapUri function to launch the desired page in the application. In such cases, the PeerFinder approach to launch the same app on another device becomes more reliable option for developers.</p>
<p>So, how do you launch the same app on another device using PeerFinder? The solution is pretty simple. Developers just need to include the following code in their application. As it requires NFC to make tapping gesture work, the application needs to have ID_CAP_PROXIMITY and ID_REQ_NFC defined in the manifest.<br />
<code><br />
...<br />
PeerFinder.TriggeredConnectionStateChanged += PeerFinder_TriggeredConnectionStateChanged;<br />
PeerFinder.Start();<br />
...<br />
void PeerFinder_TriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs args)<br />
{<br />
//to-do<br />
}<br />
</code><br />
After PeerFinder is started on device A, then when another device (&#8220;B&#8221;) enters into proximity range, device B will behave according to the following rules:</p>
<ul>
<li>Case 1: If device A has the app but device B doesn’t, device B will get a prompt to search for the app in the store as in the first illustration.</li>
<li>Case 2: If both device A and B have the app installed and the app is not yet launched on B, then B will get a prompt to launch the app as in the second illustration.</li>
<li>Case 3: If both device A and B have the app installed and both have launched the same app, then TriggeredConnectionStateChanged will get notified and further actions can be performed.</li>
</ul>
<p><a href="http://www.developer.nokia.com/Blogs/Code/files/2013/04/peerfinder_app_not_installed.png"><img class="size-medium wp-image-991" alt="App not installed" src="http://www.developer.nokia.com/Blogs/Code/files/2013/04/peerfinder_app_not_installed-180x300.png" width="180" height="300" /></a>    <a href="http://www.developer.nokia.com/Blogs/Code/files/2013/04/peerfinder_app_installed_not_launched.png"><img class="size-medium wp-image-990" alt="App not installed and not launched" src="http://www.developer.nokia.com/Blogs/Code/files/2013/04/peerfinder_app_installed_not_launched-180x300.png" width="180" height="300" /></a></p>
<p>If the app needs a socket connection for further action between two devices, then it can check the TriggeredConnectState property in the  TriggeredConnectionStateChangedEventArgs passed in with the  TriggeredConnectionStateChanged event. Once the state is changed to TriggeredConnectState.completed, <b>then the Socket property under TriggeredConnectionStateChangedEventArgs will be ready to use.</b></p>
<p>Some developers want to distinguish between normal application launching and launching by PeerFinder. This can be achieved by using the URI mapper and checking the URI passed. In the PeerFinder case, the URI passed to the MapUri function will look like this:<br />
<code><br />
/MainPage.xaml?ms_nfp_launchargs=Windows.Networking.Proximity.PeerFinder:StreamSocket<br />
</code></p>
<p>Launching the same app on another device using PeerFinder does not require URI association, which implies that no other application can pretend to be the application by associating the same URI theme. This ensures that only the expected app is launched. It also resolves the issue mentioned above in the FAR or BackgroundExecution case. However, if developers want to share their application experiences with other applications, then using ProximityDevice with URI association is the proper option to choose.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.developer.nokia.com/Blogs/Code/2013/04/08/use-the-peerfinder-api-to-launch-applications-via-nfc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
