<?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>klauskomenda.com &#187; Mobile</title>
	<atom:link href="http://www.klauskomenda.com/archives/category/mobile/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.klauskomenda.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 14 Dec 2011 23:58:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Boost the performance of your mobile web app using YUI Compressor</title>
		<link>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/</link>
		<comments>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 23:58:03 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=1069</guid>
		<description><![CDATA[This article describes how to reduce HTTP requests by integrating YUI Compressor into Xcode build settings.]]></description>
			<content:encoded><![CDATA[<p>From well established <a href="http://developer.yahoo.com/performance/rules.html">web performance guidelines</a>, we learned a few years ago that it has certain enhancing effects to the performance of a website if the number of <a href="http://en.wikipedia.org/wiki/Http"><abbr title="Hypertext Transfer Protocol">HTTP</abbr></a> requests made to external assets is reduced and their content is stripped of any unnecessary characters or content. This is commonly referred to as concatenation and minification of, in our case, JavaScript and CSS files. Knowing that byte size and HTTP requests matter even more on mobile devices, the following article attempts to explain how to achieve such performance boost using <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> in an Xcode project. </p>
<p>While working on version 2 of <a href="/apps/bikenav/">BikeNav</a>, I attempted to make some improvements not only to the app itself, but also to my development and build environment. Streamlining the process of minification was one of the goals I had in mind. The following step-by-step guide illustrates how I integrated YUI Compressor into the BikeNav Xcode project, which in itself is a <a href="http://phonegap.com/">PhoneGap</a> project. Nevertheless, this can be applied to any mobile web application that stores assets (HTML, CSS and JavaScript) on the device itself.</p>
<h2>Step 1: Download YUI Compressor</h2>
<p>Obviously we need to <a href="http://yuilibrary.com/download/yuicompressor/">download</a> YUI Compressor first. After downloading and extracting the ZIP file, we end up with a folder <span class="code">yuicompressor-[version-number]</span>. I decided to copy that folder into my iOS project folder into a directory <span class="code">tools</span>, that I had created earlier. The final path to the YUI Compressor folder would be:</p>
<pre><code>/Users/komenda/Documents/PhoneGapApps/BikeNav2/tools/yuicompressor-2.4.2</code></pre>
<h2>Step 2: Create a Shell Script File</h2>
<p>Since YUI Compressor only handles minification for us, we need to make sure that our JavaScript and CSS files are concatenated into one file each before fed to the Compressor. Also, in order to include this step into the iOS build process, we need to point the build settings to some file it can execute. I decided to create another folder in my iOS project directory called <span class="code">scripts</span> in which I created a shell script called <span class="code">bikenav_build.sh</span> which will hold the shell commands to concat the files first and then call YUI Compressor to minify them.</p>
<pre><code>$ pwd
/Users/komenda/Documents/PhoneGapApps/BikeNav2/scripts
$ ls -l
total 8
-rwxrwxrwx@ 1 komenda  _lpoperator  1098 Nov  8 15:51 bikenav_build.sh</code></pre>
<h2>Step 3: The Build Script</h2>
<h3>rsync</h3>
<p>In order to be able to do development in the browser before pushing anything on to the iOS Simulator or the device, I had set up my dev environment in such a way that I am serving all the BikeNav code from within my local Apache DocumentRoot (since there is no server-side processing involved, Apache is not even necessary, but because I store all my other projects in there as well, it keeps things nice and tidy). The path and folder structure looks like this:</p>
<pre><code>$ pwd
/Users/komenda/Webroot/BikeNav
$ ls -l
total 264
drwxr-xr-x  18 komenda  _lpoperator     612 Nov  8 16:35 audio
drwxr-xr-x   5 komenda  _lpoperator     170 Oct 24 17:11 css
drwxr-xr-x  27 komenda  _lpoperator     918 Oct 29 16:46 img
-rw-r--r--   1 komenda  _lpoperator   12497 Nov  8 17:48 index.html
drwxr-xr-x  13 komenda  _lpoperator     442 Nov  8 15:49 js
-rw-r--r--   1 komenda  _lpoperator  116575 Aug 17 17:33 phonegap-1.0.0.js</code></pre>
<p>Once I reach a certain point during development where I feel it is time to try things out on simulator or device, I sync this directory with the <span class="code">www</span> directory inside the iOS/PhoneGap project. A great tool to do this is rsync, which already comes with Mac OSX. The following command is how I run rsync when working on BikeNav (from inside the <span class="code">scripts</span> directory in the iOS project). For details on rsync command line options please refer to the <a href="http://www.samba.org/ftp/rsync/rsync.html">documentation</a>.</p>
<pre><code>rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/</code></pre>
<p>This is also the first thing I put into the <span class="code">bikenav_build.sh</span> script:</p>
<pre><code>#!/bin/bash

echo "Custom BikeNav build script"
echo "==========================="

echo "Step 1: rsync files from web directory"

rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/</code></pre>
<h3>Concatenation</h3>
<p>As mentioned above, we need to concatenate our JavaScript and CSS files into one single file each before passing it on to the YUI Compressor for minification. For this, we simply use the Unix <span class="code">cat</span> command like so:</p>
<pre><code>cat ../www/js/one.js ../www/js/two.js ../www/js/three.js &gt; ../www/js/combined.js
cat ../www/css/one.css ../www/css/two.css &gt; ../www/css/combined.css</code></pre>
<p>These two commands create two new files, <span class="code">combined.js</span> and <span class="code">combined.css</span>, each holding the contents of the JavaScript and CSS files, respectively. With that, we are now ready to give the YUI Compressor something to&#8230;well&#8230;compress.</p>
<h3>Minification</h3>
<p>Now we can send YUI Compressor to work to give us a nicely minified JavaScript and CSS files:</p>
<pre><code>java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/js/bikenav.min.js ../www/js/combined.js
java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/css/bikenav.min.css ../www/css/combined.css</code></pre>
<p>This will create <span class="code">bikenav.min.js</span> and <span class="code">bikenav.min.css</span> in their respective directories, based on the concatenated files created in the previous step. With some additional output and commenting as well as deleting the concatenated files after minification (since we don&#8217;t need them any more after that) the final <span class="code">bikenav_build.sh</span> script looks like this:</p>
<pre><code>#!/bin/bash

echo "Custom BikeNav build script"
echo "==========================="

echo "Step 1: rsync files from web directory"

rsync -avz --exclude 'index.html' --delete ~/Webroot/BikeNav/ ../www/

echo "Step 2: minify JavaScript and CSS files"

echo "=== JavaScript ==="
echo "concatinating files"

cat ../www/js/one.js ../www/js/two.js ../www/js/three.js &gt; ../www/js/combined.js

echo "minifying files"

java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/js/bikenav.min.js ../www/js/combined.js

echo "removing combined.js"

rm ../www/js/combined.js

echo "=== CSS ==="
echo "concatinating files"
cat ../www/css/one.css ../www/css/two.css &gt; ../www/css/combined.css

echo "minifying files"

java -jar ../tools/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar -o ../www/css/bikenav.min.css ../www/css/combined.css

echo "removing combined.css"

rm ../www/css/combined.css</code></pre>
<h2>Step 4: Integration into iOS Build Settings</h2>
<p>Now that we got our build script ready, we need to integrate it into the build process of our project in Xcode. The following instructions are based on the Xcode 4 user interface. </p>
<ol>
<li>After opening the project, make sure that the &#8220;Project Navigator&#8221; view is selected</li>
<li>Select the top level project, in my case it would be BikeNav</li>
<li>In the project editor window, select the target, BikeNav in my case</li>
<li>Select &#8220;Build Phases&#8221;</li>
<li>In the lower right corner, select the + sign labeled &#8220;Add Build Phase&#8221; and select &#8220;Add Run Script&#8221;</li>
</ol>
<p>After going through these steps, a new bar in the sequence of Build Phases will show up labeled &#8220;Run Script&#8221;. Because we want to run our build script before any data is copied onto the simulator or device, we need to move it up in the sequence (I put it right after &#8220;Target Dependencies&#8221;). Now we only need to specify the path to the build script and how to run it. Therefor, in the text area inside that &#8220;Run Script&#8221; phase, I put the following:</p>
<pre><code>cd /Users/komenda/Documents/PhoneGapApps/BikeNav2/scripts
./bikenav_build.sh</code></pre>
<p>For better illustration, have a look at this <a class="lightbox" title="Custom Build Script integration" href="http://www.klauskomenda.com/wp-content/uploads/2011/12/xcode_800.png">screenshot</a>, showing how that &#8220;Build Phase&#8221; section should look like after you added our build script.</p>
<h2>Step 5: Testing</h2>
<p>To test whether everything works correctly, build and run your project either on the iOS Simulator or an actual device. To verify that the script is being run, select the &#8220;Log Navigator&#8221; in the Xcode UI and then &#8220;Build [Projectname]&#8221; in the left sidebar. In the &#8220;Build target [projectname]&#8221; section in the log output you should see an entry &#8220;Run custom shell script &#8216;Run Script&#8217;&#8221;, which should show the familiar commenting messages we put in the shell script.</p>
<p>As a sidenote, of course in order to use the minified files, these need to be properly referenced in the <span class="code">index.html</span> of your project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/12/14/boost-the-performance-of-your-mobile-web-app-using-yui-compressor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Text to speech functionality in web applications using the iSpeech API</title>
		<link>http://www.klauskomenda.com/archives/2011/11/11/text-to-speech-functionality-in-web-applications-using-the-ispeech-api/</link>
		<comments>http://www.klauskomenda.com/archives/2011/11/11/text-to-speech-functionality-in-web-applications-using-the-ispeech-api/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 23:02:40 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[ispeech]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[text-to-speech]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=1067</guid>
		<description><![CDATA[Speech-enable your web applications using the iSpeech REST API. ]]></description>
			<content:encoded><![CDATA[<p>&#8220;Turn right onto Main Street&#8221;. If you are using a car navigation system like <a href="http://www.garmin.com/us/products/ontheroad">Garmin</a> or <a href="http://www.tomtom.com/">TomTom</a>, you will be all too familiar with phrases like this, spoken to you by the device mounted to your dashboard, magically guiding you through the maze of local roads and highways to your destination. Such <a href="http://en.wikipedia.org/wiki/Text_to_speech">text-to-speech</a> capabilities are usually associated with native software implementations, not so much with web applications. With the <a href="http://www.ispeech.org/developers">iSpeech API</a>, that changes. You can now build web applications that implement text-to-speech functionality with the power of JavaScript and HTML5.</p>
<p>The <a href="http://www.ispeech.org/text.to.speech.demo.php">iSpeech demo page</a> gives you an idea of the power of the API by providing a regular text input and being able to turn any text into spoken words. Let&#8217;s have a closer look now as to what is required to make this work in a web application.</p>
<h2>Step 1: Sign up for a Developer Account and set up an API key</h2>
<p><a href="http://www.ispeech.org/developer/signup/stage1">Signing up for a developer account</a> is a requirement in order to use the API. After creating your account and logging in, you can <a href="http://www.ispeech.org/developer/createkey">create a new API key</a>. Fill in the form and select &#8220;Desktop, Web, Other&#8221; as the application type in order to be able to use iSpeech&#8217;s REST API.</p>
<h2>Step 2: Trying out the API</h2>
<p>After creating an API key, you should find it in <a href="http://www.ispeech.org/developer/readallkeys">your list of available API keys</a>. Clicking on &#8220;Settings&#8221; leads you to a form where you can set certain parameters for the text-to-speech functionality, like file formats, bit rates and frequency as well as add some more information about the app that uses the key. For this step, we just want to try out the API and get some text converted into speech, so the first thing we need to do is familiarize ourselves with how the API request is constructed. iSpeech provides <a href="http://www.ispeech.org/api">good documentation</a> on that and gives us the general layout of the request:</p>
<pre><code>http://api.ispeech.org/api/rest?apikey=YOURAPIKEYHERE&amp;action=convert&amp;text=This+is+the+text+I+want+to+convert</code></pre>
<p>Now we only need to replace YOURAPIKEYHERE with the API key we created in Step 1 and copy that request URL to the address bar of our browser or create an <a href="http://html5doctor.com/native-audio-in-the-browser/">HTML5 audio element</a> like the one below to embed in our HTML document.</p>
<p><audio controls preload="auto" autobuffer><source src="http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&#038;action=convert&#038;text=This+is+the+text+I+want+to+convert" /><source src="http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&#038;action=convert&#038;text=This+is+the+text+I+want+to+convert&#038;format=ogg" /><source src="http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&#038;action=convert&#038;text=This+is+the+text+I+want+to+convert&#038;format=wav" /></audio></p>
<h2>Step 3: Tweaking the Request Parameters</h2>
<p>The attentive reader might have noticed, from looking at the source code of the audio element in step 2, that we need to provide several fallback versions in addition to the MP3 format that the iSpeech API generates by default. This is necessary to satisfy the different codec requirements by modern browsers. To achieve this, the iSpeech API has a <span class="code">format</span> parameter, that lets us specify the format in which we would like the audio piece to be returned to us. A complete list of supported formats can be found in the <a href="http://www.ispeech.org/api">iSpeech API documentation</a>. </p>
<p>If we want to use the <a href="http://en.wikipedia.org/wiki/Ogg_vorbis">Ogg Vorbis</a> format, we can specify this like this:</p>
<pre><code>http://api.ispeech.org/api/rest?apikey=YOURAPIKEYHERE&amp;action=convert&amp;text=This+is+the+text+I+want+to+convert&amp;format=ogg</code></pre>
<p>We can also specify a different voice using the &#8220;voice&#8221; parameter:</p>
<pre><code>http://api.ispeech.org/api/rest?apikey=YOURAPIKEYHERE&amp;action=convert&amp;text=This+is+the+text+I+want+to+convert&amp;format=ogg&amp;voice=auenglishfemale</code></pre>
<p>It is also possible to slow down the voice by providing a &#8220;speed&#8221; parameter with values between -10 (very slow) and 10 (very fast). However I noticed that not all voices provided by iSpeech support this parameter.</p>
<pre><code>http://api.ispeech.org/api/rest?apikey=YOURAPIKEYHERE&amp;action=convert&amp;text=This+is+the+text+I+want+to+convert&amp;format=ogg&amp;speed=-5</code></pre>
<h2>Sounds great (literally), but&hellip;</h2>
<p>By this point it is probably obvious that being able to use this text-to-speech API from within HTML documents using regular web technologies is pretty powerful. However, there is a catch to it in the name of costs. The web API key that we created is free for the first 500 words being transformed to audio by the API (you can check your key&#8217;s total word balance on the settings page of the key). If you exceed that limit, you have to pay, $50 for 1000 word credits to be exact, which essentially means that you can only feasibly use this API in some sort of premium app setting where your revenue generated can cover for these costs. While I would love this technology to be free, I can understand that it is not, considering the amount of work that goes into developing such piece of software. </p>
<p>The upside is, however, that iSpeech in addition to the REST API also offers SDKs for pretty much all popular mobile platforms, such as the <a href="http://www.ispeech.org/developers/iphone">iPhone</a>, and API keys generated for these do not have any word quota imposed on them. Maybe another good reason to start learning Objective-C.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/11/11/text-to-speech-functionality-in-web-applications-using-the-ispeech-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Search along a route with CloudMade&#8217;s Local Search API</title>
		<link>http://www.klauskomenda.com/archives/2011/11/06/search-along-a-route-with-cloudmades-local-search-api/</link>
		<comments>http://www.klauskomenda.com/archives/2011/11/06/search-along-a-route-with-cloudmades-local-search-api/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 05:09:49 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[bikenav]]></category>
		<category><![CDATA[cloudmade]]></category>
		<category><![CDATA[local search]]></category>
		<category><![CDATA[search along route]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=1065</guid>
		<description><![CDATA[A tutorial demonstrating how to give users functionality that they were used to get only from their car navigation systems.]]></description>
			<content:encoded><![CDATA[<p>Suppose you go on a casual bike ride with a couple of friends. Wouldn&#8217;t it be nice to know if there are any coffee shops located along the route to refuel on caffeine and sugar? Or lets say you are doing a longer ride and would want to pick up a spare tube along the way. It would be good to know if there is any bike shop conveniently located along the route. Meet <a href="http://developers.cloudmade.com/projects/local-search/examples/searching-for-objects-along-route">CloudMade&#8217;s Local Search API</a>, which I used to power this specific feature in the most recent version of <a href="/apps/bikenav/">BikeNav</a>. This article is going to show you how you can include that in your next mobile-aware app.</p>
<h2>Step 1: Sign up for a Developer Account and get an API key</h2>
<p>CloudMade lets you <a href="http://cloudmade.com/register">sign up for a developer account</a> for free. After completing that initial step, access your account and click on the &#8220;Get API Key&#8221; button. Fill the details into the form presented to you, selecting &#8220;Web&#8221; as the platform and the &#8220;Free&#8221; pricing plan. Since we will not use any of the <a href="http://cloudmade.com/select/web">other features</a> the API provides, the free version has more than we need.</p>
<h2>Step 2: Create a token from your API key</h2>
<p>In order to be able to communicate with CloudMade&#8217;s servers, you need to create an access token from your API key. This is done by sending an HTTP POST request to a particular authentication server as noted in <a href="http://developers.cloudmade.com/projects/show/auth">their documentation</a>. If you are using PHP, the following code can help you out (using <a href="http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/">Wez Furlong&#8217;s do_post_request function</a>).</p>
<pre><code>$apiKey = 'my-api-key';
$userId = 'your-generated-user-id';

// http://wezfurlong.org/blog/2006/nov/http-post-from-php-without-curl/
function do_post_request($url, $data, $optional_headers = null)
{
  $params = array('http' =&gt; array(
              'method' =&gt; 'POST',
              'content' =&gt; $data
            ));
  if ($optional_headers !== null) {
    $params['http']['header'] = $optional_headers;
  }
  $ctx = stream_context_create($params);
  $fp = @fopen($url, 'rb', false, $ctx);
  if (!$fp) {
    throw new Exception("Problem with $url, $php_errormsg");
  }
  $response = @stream_get_contents($fp);
  if ($response === false) {
    throw new Exception("Problem reading data from $url, $php_errormsg");
  }
  return $response;
}
$token =  do_post_request('http://auth.cloudmade.com/token/' . $apiKey . '?userid=' . $userId, '');

echo "generated token: " . $token;</code></pre>
<h2>Step 3: Requesting POI data along a given route</h2>
<p>Equipped with the token from Step 2, we can now try to retrieve POIs along the route. The following example would do a search along the route for a maximum of 20 points of interest of type &#8220;cafe&#8221; from my place to Cupertino, within a radius of 1 kilometer and returning the data in <a href="http://en.wikipedia.org/wiki/JSONP">JSONP</a> format.</p>
<pre><code>http://geocoding.cloudmade.com/[APIKEY]/geocoding/v2/find.js?token=[TOKEN]&amp;object_type=cafe&amp;along=37.36721,-122.03533,37.36756,-122.0354,37.36752,-122.03662,37.36672,-122.03607,37.36642,-122.03648,37.36429,-122.03288,37.33911,-122.03241,37.33763,-122.03239,37.32283,-122.03241&amp;distance=1000&amp;results=20&amp;callback=mySuperCallback</code></pre>
<p>The <a href="http://developers.cloudmade.com/wiki/geocoding-http-api/Documentation">find method</a> of the Local Search API lets you pass in various parameters, which are <a href="http://developers.cloudmade.com/wiki/geocoding-http-api/Documentation#Parameters">well documented</a>. For the purpose of this article, the following are the most important ones:</p>
<ul>
<li><span class="highlight">object_type</span>: the API lets you choose from an <a href="http://developers.cloudmade.com/wiki/geocoding-http-api/Object_Types">extensive list of point-of-interest types</a>
</li>
<li><span class="highlight">along</span>: vector of the route your are traveling along, i.e. a comma separated list of lat/long pairs</li>
<li><span class="highlight">distance</span>: radius of the search are in meters</li>
<li><span class="highlight">results</span>: number of results to return</li>
<li><span class="highlight">callback</span>: signaling the server to return the response in JSONP format and specifying a publicly accessible JavaScript function to execute, passing in the response data</li>
</ul>
<p>The result from the above request will come back as JSONP and look similar to the following:</p>
<pre><code>mySuperCallback({
    "found": "3",
    "bounds": [{
        "json": ["37.33155", "-122.03642"]
    }, {
        "json": ["37.36805", "-122.03266"]
    }],
    "features": [{
        "id": "7367785",
        "centroid": {
            "type": "POINT",
            "coordinates": ["37.36768", "-122.03642"]
        },
        "bounds": [{
            "json": ["37.36768", "-122.03642"]
        }, {
            "json": ["37.36768", "-122.03642"]
        }],
        "properties": {
            "operator": "Starbucks",
            "osm_element": "node",
            "amenity": "cafe",
            "synthesized_name": "Cafe",
            "osm_id": "266625630"
        },
        "type": "Feature"
    }, {
        "id": "26073213",
        "centroid": {
            "type": "POINT",
            "coordinates": ["37.33155", "-122.03266"]
        },
        "bounds": [{
            "json": ["37.33155", "-122.03266"]
        }, {
            "json": ["37.33155", "-122.03266"]
        }],
        "properties": {
            "osm_element": "node",
            "amenity": "cafe",
            "name": "Bagel Street Cafe",
            "osm_id": "957085286"
        },
        "type": "Feature"
    }, {
        "id": "14342531",
        "centroid": {
            "type": "POINT",
            "coordinates": ["37.36805", "-122.03338"]
        },
        "bounds": [{
            "json": ["37.36805", "-122.03338"]
        }, {
            "json": ["37.36805", "-122.03338"]
        }],
        "properties": {
            "osm_element": "node",
            "amenity": "cafe",
            "name": "Peet's Coffee",
            "osm_id": "441987522"
        },
        "type": "Feature"
    }],
    "type": "FeatureCollection",
    "crs": {
        "type": "EPSG",
        "properties": {
            "code": "4326",
            "coordinate_order": ["0", "1"]
        }
    }
});</code></pre>
<p>In our <span class="code">mySuperCallback</span> function we can then use this data to e.g. plot each of the returned points of interest on a map, in addition to the given route. </p>
<h2>Be aware of long routes</h2>
<p>Attentive readers will notice that there is a slight flaw in the way the request is constructed. If you have a long route with a lot of waypoints that you are passing along in the request to the search API, at some point you will reach the limit of the maximum amount of characters you can pass along in a URL. One way to mitigate this is to drop every other entry from the array of waypoints if the number exceeds a certain limit. That way, the search will still be somewhat accurate (since you are only taking out points in between instead of cutting them off at the beginning or the end). A JavaScript example code could look like this:</p>
<pre><code>maxWaypoints = 160; // a good threshold that I noticed works well for BikeNav
waypoints = [ ... ]; // array where each entry represents a waypoint along the route
no_of_waypoints = waypoints.length;

if (no_of_waypoints &gt; maxWaypoints) {
    while (waypoints.length &gt; maxWaypoints) {
        for (var i = 0, len = waypoints.length; i &lt; len; i++) {
            waypoints.splice(i + 2, 1);
        }
    }
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/11/06/search-along-a-route-with-cloudmades-local-search-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BikeNav featured in Bicycling Magazine</title>
		<link>http://www.klauskomenda.com/archives/2011/11/06/bikenav-featured-in-bicycling-magazine/</link>
		<comments>http://www.klauskomenda.com/archives/2011/11/06/bikenav-featured-in-bicycling-magazine/#comments</comments>
		<pubDate>Mon, 07 Nov 2011 03:10:13 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Cycling]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[bicycle]]></category>
		<category><![CDATA[bike]]></category>
		<category><![CDATA[bikenav]]></category>
		<category><![CDATA[cycling]]></category>
		<category><![CDATA[mobile development]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=1061</guid>
		<description><![CDATA[Launching an app into the App Store is great. Being featured by a magazine is even better.]]></description>
			<content:encoded><![CDATA[<p>It is always nice to see when other people like and use the software you release. I remember when I launched the first version of <a href="/apps/bikenav/">BikeNav</a> back in March of this year and saw it listed on the <a href="http://itunes.apple.com/us/app/bikenav/id428665758">App Store</a>, I certainly felt a big feeling of accomplishment. However, the joy was even bigger when I found out that a <a href="http://www.bicycling.com/">magazine publication</a> took notice.</p>
<p><a href="http://www.flickr.com/photos/commander_klaus/6321017500/in/photostream"><img class="img-left" style="width: 293px" src="http://farm7.static.flickr.com/6226/6321017500_1bf4d4d738.jpg"></a>A couple of weeks ago I got contacted by someone from Bicycling Magazine, which has been providing the bike community with bike gear and equipment reviews, training plans, maintenance how-to&#8217;s and more for 47 years, that they would like to feature my application in their December issue. This was great news and really the best thing that could have happened, considering the state the development process was in. I had hit some technical difficulties when working on an update version of the application back in May and combined with higher load at work and less free time, I had lost interest a bit in improving the application. The interest from the magazine, combined with the news that the piece will be contributed by <a href="http://www.dcrainmaker.com/">Ray Maker</a> (whose blog should be your #1 destination if you are interested in any kinds of gear reviews when it comes to outdoor and endurance sports), gave me the spark that I needed to continue working and improving the app. </p>
<p>Motivated by this attention that I had received, I spent huge chunks of my spare time since to improve the app, which led to the release of version 2 of BikeNav on pretty much the same date&mdash;incidentally&mdash;as the publish date of the <a href="http://www.flickr.com/photos/commander_klaus/6320493851/in/photostream/">December issue of Bicycling Magazine</a>. And just today I was able to pick up a copy and found, with great joy, a little paragraph about my app in the upper right hand corner on <a href="http://www.flickr.com/photos/commander_klaus/6321017796/in/photostream/">page 20</a>. Nothing big. Nothing fancy. But still something.</p>
<h2>BikeNav 2.0: The tech details</h2>
<p>What was holding me back a little bit since the release of version 1 was that I was an earlier adopter of <a href="http://jquerymobile.com/">jQuery Mobile</a>, having used their first alpha release for my initial version. The upgrade to a more stable version always seemed too painful and time consuming and so I kept adding hack after hack on top of an understandably buggy (in parts) version of the framework. In addition, I was also using a 0.9.x release of <a href="http://phonegap.com/">phoneGap</a> to power BikeNav.</p>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/11/logo.png" class="img-right" alt="" title="logo" width="147" height="147" class="alignnone size-full wp-image-1089" />With version 2, both of the frameworks were upgraded to their most recent version. In addition, I also gave the application a bit of a UI overhaul, abandoning the black &amp; white look from the initial version and introducing a new splash screen, updating the logo to feature a blue color tone instead of black and cleaning up the interface in general. I also introduced new features, like the ability to search for points of interests along a route using the <a href="http://developers.cloudmade.com/projects/local-search/examples/searching-for-objects-along-route">CloudMade&#8217;s Local Search API</a> and being able to add custom location pins to the map. </p>
<p>The attention that I got from the magazine and from the occasional user who emails with his feedback certainly motivates me to keep working on BikeNav. In addition to being a very useful app for bicyclists, it is also a great playground for me to see how far I can get with the hybrid mobile application approach, where the majority of the heavy lifting is done using web technologies.</p>
<p>So if you are a cyclist and haven&#8217;t checked out my app, please do so. And after you are done, feel free to <a href="/contact/">send me feedback</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/11/06/bikenav-featured-in-bicycling-magazine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BikeNav: My first iPhone App</title>
		<link>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/</link>
		<comments>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 05:35:04 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bicycle]]></category>
		<category><![CDATA[bike]]></category>
		<category><![CDATA[cycling]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[sports]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=922</guid>
		<description><![CDATA[I am giving some insights into the decisions that went into building BikeNav, my first iPhone application, using jQuery Mobile and PhoneGap. ]]></description>
			<content:encoded><![CDATA[<p>I have been intrigued by mobile application development ever since working on <a href="http://www.amazon.com/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X">my thesis</a> in 2006. Lots of time has passed and so much has changed since then. 5 years back, I had to revert to <a href="http://en.wikipedia.org/wiki/J2me">J2ME</a> to get an application working on a Nokia <a href="http://en.wikipedia.org/wiki/Series_60">Series 60</a> phone. These days, I can use <a href="http://en.wikipedia.org/wiki/HTML5">HTML5</a> (in conjunction with <a href="http://www.phonegap.com/">PhoneGap</a>) to deploy a native-like application to the Apple App Store to offer it on the iPhone market. However, it was important to me to pick an application that I would use personally and so I came up with <a href="http://www.klauskomenda.com/apps/bikenav/">BikeNav</a>, the route planner for your next bike ride to work, to shop for groceries or to visit a friend. </p>
<h2>What is it?</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/04/bikenav_logo.png" alt="" title="bikenav_logo" width="147" height="147" class="img-right" />I really like to use my bike as a clean way of transportation but when going from A to B by bike, it is especially vital in car-dominated USA to pick a route that preferably has some sort of bike lane in order for the cars to give you some space or where the speed limit is at a reasonable level (i.e. residential streets). The native map application on the iPhone already has routing functionality built in for public transport, walking and when driving with your car, but not for biking. Interestingly though, the desktop version of <a href="http://maps.google.com/">Google Maps</a> has this functionality (<a href="http://google-latlong.blogspot.com/2010/03/its-time-to-bike.html">launched in March 2010 for several cities in the US and Canada</a>). So in order to fill this gap, I had the idea for BikeNav, which uses this Google Maps functionality to give the user the most bicycle friendly route from A to B. </p>
<p>Further details about the features of the application as well as screenshots can be found on the <a href="http://itunes.apple.com/us/app/bikenav/id428665758">App Store</a> as well as on my <a href="http://www.klauskomenda.com/apps/bikenav/">support page</a>. Below I will focus more on an overview of the technical implementation of the application.</p>
<h2>The Tech</h2>
<p>After looking into Objective-C and native iPhone development, it became clear to me rather quickly that I should stay with what I am good at, meaning web development technologies. Objective-C as well as how all the different pieces fit together in XCode was just hugely confusing, which made me decide that if I can somehow use web technologies to achieve what I want then I am certainly going to go for that <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<h3>jQuery Mobile</h3>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/04/jquery_mobile_logo.png" alt="" title="jquery_mobile_logo" width="293" height="101" class="img-left" />I had to do some research at work on Mobile JavaScript Frameworks and looked into two of them that got mentioned quite a lot: <a href="http://jquerymobile.com/">jQuery Mobile</a> and <a href="http://www.sencha.com/products/touch/">Sencha Touch</a>. I had never really worked with jQuery and Sencha was completely new to me, but looking at jQuery Mobile, I realized that it might give me more freedom than Sencha with regards to being able to easily style and access the interface elements that I needed for the application. The only downside I could see was that, at the time, it was in Alpha 1 release, indicating that there might still be some bugs (which turned out to be true and I had to work around them while developing). As of this writing, jQuery Mobile is now in <a href="http://jquerymobile.com/blog/2011/04/07/jquery-alpha-4-1-maintenance-release/">Alpha 4.1</a>.</p>
<h3>PhoneGap</h3>
<p><img width="293" height="109" class="img-right" alt="" src="http://www.klauskomenda.com/wp-content/uploads/2011/01/phonegap_logo.jpg">Because I wanted to deploy my application on the Apple App Store, I had to find a way to somehow turn my mobile application into a native(-like) app. PhoneGap to the rescue. PhoneGap gives the developer the ability to wrap a web application (written in HTML, CSS and JavaScript) into a native shell that gives it the needed characteristics in order to push it to the App Store, the same way as you would if it were an Objective-C application. In addition, PhoneGap provides a JavaScript bridge, that lets you access native device capabilities (i.e. access to the contact list on the device) from within your application using JavaScript.</p>
<h2>Lessons learned and &#8220;What&#8217;s next?&#8221;</h2>
<p>Initially I made the decision to go with jQuery Mobile because I felt it would give me more flexibility with regards to being able to easily build up my interface elements, since the framework lets you build a mobile web app very much the same way you would build a web site or web app for the desktop. With Sencha Touch, it seemed that it would have been more difficult to come up with a non-standard interface (like I wanted to use) for my app, since all the control is in JavaScript, with very few things defined in HTML and CSS. Alternatively, I probably could have used <a href="http://www.appcelerator.com/products/titanium-mobile-application-development/">Titanium</a> as well, but again, I felt it would have been more of a challenge to get the positioning and styling of all the elements the way I wanted it&mdash;since Titanium also has an &#8216;all JavaScript&#8217; approach. </p>
<h3>Adopting early has its downsides</h3>
<p>As I mentioned earlier, the slight downside to using jQuery Mobile was (and still is) that it was in an early Alpha release. I actually started developing with Alpha 1, meanwhile it is in Alpha 4.1. I only tried to upgrade once, about half-way through development, and noticed that lots of things had been broken by the update. So I reverted back to Alpha 1, and worked my way around the bugs and the missing features that just weren&#8217;t there at the time. Since I would like to also offer the application on Android phones at some point, I need to upgrade eventually, but I think I will wait until the framework is at least out of its Alpha state. </p>
<h3>Bridging the gap</h3>
<p>I am, however, very pleased so far with PhoneGap. Getting it installed was easy and building the application out of XCode code is very straight forward as well. All I had to do was copy my HTML, CSS, JavaScript and image files into the www folder of the project and hit &#8216;build &#038; run&#8217;. Granted, I am not using the PhoneGap JavaScript bridge in this application to access native device features (yet) and I also haven&#8217;t used PhoneGap for building BikeNav for Android (yet), so there might be potential hurdles to overcome in this regard. But from what I have seen so far, the combination of jQuery Mobile and PhoneGap works very well for me. </p>
<p>In terms of new features, I would love to do some research on what options there are (if any) to do &#8216;text to speech&#8217; in JavaScript (for reading out driving directions) as well as integration of <a href="http://en.wikipedia.org/wiki/Google_Street_View">Google Street View</a> images into the application. If you like to bike (and you own an iPhone and live in the US or Canada), I would certainly encourage you to download it, try it out and <a href="http://www.klauskomenda.com/contact/">give me feedback</a>! Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/04/29/bikenav-my-first-iphone-app/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A look at PhoneGap and Appcelerator Titanium</title>
		<link>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/</link>
		<comments>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 23:09:28 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[framworks]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mobile development]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=853</guid>
		<description><![CDATA[Having been interested into mobile development for quite a while, I had a chance to look at two frameworks that make developing apps for web developers much easier. Without Objective-C or Java.]]></description>
			<content:encoded><![CDATA[<p>Ever since I had started working on my project for my diploma thesis, I was fascinated by the capabilities of smart phones (at the time, in 2006, 3G had just come out in Austria). Even though I had a lot of fun, learned a lot and <a href="archives/2008/12/13/location-based-services-my-book-on-amazon/">even got my thesis published</a>, for one reason or the other, I never really dared to venture into the whole mobile application development sphere professionally, thinking I should stay where I feel comfortable&mdash;web development. However, the developments over the last years, mainly around the <a href="http://www.apple.com/iphone/">iPhone</a>, but also recently regarding <a href="http://www.android.com/">Android</a>, brought me back to this topic I have always been very interested in. Being a web developer (and far away from a &#8220;proper&#8221; Computer Engineer), however, I still can&#8217;t wrap my head around certain technologies, i.e. languages. <a href="http://en.wikipedia.org/wiki/Java_%28software_platform%29">Java</a> is my <a href="http://en.wikipedia.org/wiki/Mount_Whitney">Mt. Whitney</a>, but <a href="http://en.wikipedia.org/wiki/Objective-C">Objective-C</a> is more like a <a href="http://en.wikipedia.org/wiki/Mount_Everest">Mt. Everest</a> to me. So I was very happy to see that there are people that acknowledged that this is a problem and developed <a href="http://en.wikipedia.org/wiki/Multiple_phone_web_based_application_framework">phone web based application frameworks</a> that people with a web development background can take and build mobile applications with. Without having to learn Objective-C. And right there they caught my attention once again.</p>
<h2>What are phone web based application frameworks?</h2>
<p>Essentially, these are frameworks that provide developers coming from a web development background a certain set of tools to use their current skillset (HTML, CSS, JavaScript) to build native or native-like mobile applications. <a href="http://www.phonegap.com/">PhoneGap</a> and <a href="http://www.appcelerator.com/">Appcelerator Titanium</a> are the most popular amongst all the frameworks out in the wild. I got to play around with both of them recently and I am going to share a summary of my findings and a look from 10,000 feet at the two below.</p>
<h2>PhoneGap</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/phonegap_logo.jpg" alt="" width="293" height="109" class="img-left" /><a href="http://phonegap.com/">PhoneGap</a>, developed by <a href="http://www.nitobi.com/">Nitobi Software</a>, gained a lot of popularity in the web development world, because of exactly what got me interested myself. On their website, it says &#8220;Build apps in HTML and JavaScript and still take advantage of core features in iPhone/iPod touch, iPad, Google Android, Palm, Symbian and Blackberry SDKs.&#8221;. Sounded exactly what the web developer but wannabe-mobile-developer needs.</p>
<p>PhoneGap projects require the underlying SDKs (e.g. iOS SDK) to be installed and typically building the application happens from an IDE, e.g. Xcode. The developer puts his files into a <span class="code">www</span> folder in the project directory. When building, PhoneGap then renders these files inside a native WebView provided by the OS-specific language (either <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/Reference/Reference.html">Objective-C</a> or <a href="http://developer.android.com/reference/android/webkit/WebView.html">Java</a>). It exposes access to certain native device features, like Contacts, Accelerometer, Camera and Notifications, through the <a href="http://docs.phonegap.com/">PhoneGap JavaScript API</a>.</p>
<p>The actual interface of the app, however, is styled with &#8216;the usual suspects&#8217;, meaning HTML and CSS. Because of the fact that UI elements are styled with CSS, these can look significantly different to native OS interface elements (e.g. buttons), as well as the performance might be not as good as if native elements were used. </p>
<p>In the end, a PhoneGap application is essentially still a web application, wrapped inside a WebView. It still remains a web application that is displayed through rendering of HTML, CSS and JavaScript using a browser instance on a mobile device. It currently supports development for the iPhone, Google Android, Symbian OS, BlackBerry and Palm operating systems.</p>
<h3>Example</h3>
<p>The following example code is taken from <a href="http://docs.phonegap.com/phonegap_contacts_contacts.md.html#contacts.find">PhoneGaps API documentation</a> to illustrate the syntax of how a PhoneGap application is put together. In this specific case, the API is used to find all contacts with the name &#8216;Bob&#8217; in any name field:</p>
<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Contact Example&lt;/title&gt;

    &lt;script type="text/javascript" charset="utf-8" src="phonegap.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" charset="utf-8"&gt;

    // Wait for PhoneGap to load
    //
    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

    // PhoneGap is ready
    //
    function onDeviceReady() {
        // find all contacts with 'Bob' in any name field
        var options = new ContactFindOptions();
        options.filter="Bob";
        var fields = ["displayName", "names"];
        navigator.service.contacts.find(fields, onSuccess, onError, options);
    }

    // onSuccess: Get a snapshot of the current contacts
    //
    function onSuccess(contacts) {
        for (var i=0; i&lt;contacts.length; i++) {
            console.log("Display Name = " + contacts[i].displayName);
        }
    }

    // onError: Failed to get the contacts
    //
    function onError() {
        alert('onError!');
    }

    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="onLoad()"&gt;
    &lt;h1&gt;Example&lt;/h1&gt;
    &lt;p&gt;Find Contacts&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</code></pre>
<h2>Appcelerator Titanium</h2>
<p><img src="http://www.klauskomenda.com/wp-content/uploads/2011/01/appcelerator_logo.png" alt="" width="293" height="100" class="img-left" /><a href="http://www.appcelerator.com/products/titanium-mobile-application-development/">Appcelerator Titanium</a> was <a href="http://www.appcelerator.com/2008/12/titanium-introduction/">launched with the same promise</a> like PhoneGap, namely to provide web developers, familiar with HTML, CSS and JavaScript, a tool to use these technologies to develop mobile applications on iOS and Android. In a way, Titanium reminds me of <a href="http://www.j2mepolish.org/cms/leftsection/introduction.html">J2ME Polish</a>, a library for Java Development on mobile devices that enables the developer to <a href="http://www.j2mepolish.org/cms/leftsection/documentation/design/visual-guide.html">create native UI elements</a> and style them using a <a href="http://www.j2mepolish.org/cms/leftsection/documentation/design/css-basics.html">CSS-like syntax</a>. Similar to PhoneGap, Titanium provides a binding layer that maps JavaScript function calls to natively available APIs. However, here is where the similarities end. The main differences to PhoneGap are:</p>
<ul>
<li><span class="highlight">Truly native applications</span>. Unlike PhoneGap, <a href="http://developer.appcelerator.com/guides/en/architecture.html">Titanium actually translates the code into native application code</a>. The application code, written in JavaScript, is being interpreted during runtime and through a bridge layer, function calls to <span class="code">Titanium.some_function</span> invoke native application code under the hood.</li>
<li><span class="highlight">Just JavaScript, no more HTML &amp; CSS</span>. Previous to version 1.0 (current version is 1.5), Titanium followed a similar approach to what PhoneGap was doing. The application code would consist of HTML, CSS and JavaScript, whereas native device services were exposed using a Titanium specific <a href="http://developer.appcelerator.com/apidoc/mobile/latest">JavaScript API</a>.  With version 1.0, HTML and CSS are gone. Code is written in pure JavaScript, using mainly functions that the Titanium API exposes. Apart from using it to access special device features (such as the camera), it also enables the developer to render native UI elements (such as tables, buttons, native maps etc.).</li>
</ul>
<p>The obvious advantage of a native application is performance. The UI will perform much better if native OS elements are used, compared to rendering HTML, CSS and JavaScript in a browser instance to e.g. create a button. As a side effect, the native look-and-feel can easily be maintained.</p>
<p>Unlike PhoneGap, building and packaging does not happen inside an IDE, but through a special piece of software called <a href="http://www.klauskomenda.com/wp-content/uploads/2011/01/titanium_developer_ss.gif" class="lightbox" title="Titanium Developer Screenshot">Titanium Developer</a>. This is the tool to set up new projects, configure, test and package them. Any IDE of your choice can be used to write the application code. </p>
<h3>Example</h3>
<p>Appcelerator provides a plethora of examples, all bundled up in their <a href="http://developer.appcelerator.com/guides/en/kitchensink.html">Kitchen Sink demo application</a>, which can be downloaded from <a href="http://github.com/appcelerator/KitchenSink">GitHub</a>. The following example, <a href="https://github.com/appcelerator/KitchenSink/blob/master/KitchenSink/Resources/examples/shake.js">taken from Kitchen Sink</a>, shows how to hook up an event listener, using the Titanium API, and display an alert window:</p>
<pre><code>var win = Titanium.UI.currentWindow;

var l = Titanium.UI.createLabel({
	text:'Shake your phone',
	top:10,
	color:'#999',
	height:'auto',
	width:'auto'
});

win.add(l);

Ti.Gesture.addEventListener('shake',function(e)
{
	Titanium.UI.createAlertDialog({title:'Shake',message:'it worked!'}).show();
});</code></pre>
<h2>Conclusion</h2>
<p>Both Phone Gap and Appcelerator Titanium give web developers the opportunity to create mobile applications without the need to learn Objective-C or Java. After the build process, both frameworks provide the developer with a packaged application that can be installed  on an actual physical device and published (e.g. using the Apple AppStore). </p>
<p><span class="highlight">PhoneGap</span> supports more Operating Systems and lets the developer essentially set up his application project like he would set up a website (e.g. with <span class="code">index.html</span>, <span class="code">css</span>, <span class="code">img</span> and <span class="code">js</span> folder etc.). PhoneGap applications are then wrapped by the framework inside a WebView during build time. This means that, upon execution, the rendering still happens inside a browser instance, which interprets the HTML, CSS and JavaScript. Compared to a truly native application, this likely means slow performance and additional effort to re-create a native experience.</p>
<p><span class="highlight">Appcelerator Titanium</span> only supports iOS and Android. Any application code is (as of version 1.0) written in pure JavaScript using mainly Titaniums JavaScript API. It seems more like a native code (Objective-C or Java) abstraction layer than code that resembles anything someone would recognize from the web development world. Unlike with PhoneGap, the developer ends up with a final software product that is truly native to the respective operating system. Because native elements are used for the interface (e.g. buttons, tables, views), the performance is better and no effort needs to be put in to recreate any native experience using HTML, CSS and JavaScript. </p>
<p>Finally, it highly depends on the requirements of the product which framework to go with. If the goal is to support as many operating systems as possible, then PhoneGap is probably the way to go. If true native-ness and performance is important, then Titanium will be the better choice. It is also important to note that only PhoneGap still holds true to their promise that a web developer can quickly jump in and use his skills to develop a mobile app. With Titanium, all the application code will be JavaScript, even the styling of elements happens through function calls (which is, arguably, still better to having to use Objective-C). An important factor for deciding which way to go would also be whether the respective JavaScript API provided offers the functionality needed for the application.</p>
<h2>Resources</h2>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Multiple_phone_web_based_application_framework">Wikipedia: multiple phone web based application framework</a> </li>
<li><a href="http://phonegap.com/">PhoneGap</a></li>
<li><a href="http://docs.phonegap.com/">PhoneGap JavaScript API docs</a></li>
<li><a href="http://appcelerator.com/">Appcelerator Titanium</a></li>
<li><a href="http://developer.appcelerator.com/guides/en/architecture.html">Overview over the Appcelerator Titanium architecture</a></li>
<li><a href="http://developer.appcelerator.com/apidoc/mobile/latest">Titanium JavaScript API docs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2011/01/17/a-look-at-phonegap-and-appcelerator-titanium/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Location Based Services &#8211; my book on Amazon</title>
		<link>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/</link>
		<comments>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 22:22:36 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Life in General]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/?p=728</guid>
		<description><![CDATA[Seeing your work published and being available on Amazon.com is something you don't really think about when writing your diploma thesis. But somehow it happened that my work about Location Based Services is now available on Amerca's largest online retailer website. I am stunned.]]></description>
			<content:encoded><![CDATA[<p>I graduated from <a href="http://www.en.fhv.at/">University</a> in 2006 in Austria and wrote my diploma thesis on <a href="http://en.wikipedia.org/wiki/Location_Based_Services">Location Based Services</a>. I talked about the foundations and technologies that need to be in place in order to provide such a service to users of cell phones and mobile devices. To round it up, I developed a prototype for a Location Based Service (a restaurant guide) in <a href="http://en.wikipedia.org/wiki/J2me">J2ME</a> as well as a corresponding website. </p>
<p><a href="http://www.amazon.de/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204521&#038;sr=8-1"><img src="http://www.klauskomenda.com/wp-content/uploads/2008/12/lbs_book_cover.gif" alt="" class="img-right" /></a>The application on the mobile phone would give you a list of restaurants, bars, cafes etc. in your proximity, as well as details about their type of cuisine, opening hours, price range etc. and how other people have rated that particular place. Based on whatever the occasion was&mdash;whether you are planning a relaxed dine-out with your family or having a more intoxicated night with friends&mdash;the tool would recommend you the best place in your area.</p>
<p>While I was working on the prototype, writing my thesis and then putting the layout together in <a href="http://www.adobe.com/de/products/indesign/">InDesign</a>, I wasn&#8217;t thinking that a publisher would ever get interested in my work. </p>
<p>But the less you expect something, the happier you are when it actually happens. About 2 months ago I received an email from <a href="http://www.vdm-verlag.de/">VDM Verlag</a> in Germany saying that they found my thesis in the library of the university and would be interested in publishing it. &#8220;How awesome is that!&#8221;, was about the reaction I had. After putting all the required details about the book into their online system and reformatting a few things to fit their requirements, I got the confirmation that everything looks good and it is off to the printers.</p>
<p>And now, just in time for Christmas <img src='http://www.klauskomenda.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , I am happy to see my book being available on <a href="http://www.amazon.com/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204532&#038;sr=8-1">Amazon.com</a> and <a href="http://www.amazon.de/Location-Based-Services-Beispiel-Lokalf%C3%BChrers/dp/363910109X/ref=sr_1_1?ie=UTF8&#038;s=books&#038;qid=1229204521&#038;sr=8-1">Amazon.de</a>. It is in German, so sorry to my non-German-speaking friends. I will most likely never reach the author status of my colleague <a href="http://www.wait-till-i.com/">Christian Heilmann</a>, who wrote <a href="http://www.amazon.com/s/ref=nb_ss_b?url=search-alias%3Dstripbooks&#038;field-keywords=christian+heilmann&#038;x=0&#038;y=0">about 167 books about web development related topics</a>, but I am very happy to see this and it makes me feel proud to see that all the work I put in at that time is now available to a wider audience. It is a really great feeling and I feel very content how it all turned out.</p>
<p>I would like to take this opportunity to thank <a href="http://www2.staff.fh-vorarlberg.ac.at/~kw/">Karl-Heinz Weidmann</a>, who was my thesis advisor, and <a href="http://www.linkedin.com/pub/1/b79/615">Werner Flatz</a>, who I worked together with during the development of my application.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/12/13/location-based-services-my-book-on-amazon/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Testing on Mobile Devices using Emulators</title>
		<link>http://www.klauskomenda.com/archives/2008/03/17/testing-on-mobile-devices-using-emulators/</link>
		<comments>http://www.klauskomenda.com/archives/2008/03/17/testing-on-mobile-devices-using-emulators/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 22:13:05 +0000</pubDate>
		<dc:creator>Klaus</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.klauskomenda.com/archives/2008/03/17/testing-on-mobile-devices-using-emulators/</guid>
		<description><![CDATA[This article aims to list options for developers who wish to test their Web sites on mobile devices using OS emulators and browser simulators.]]></description>
			<content:encoded><![CDATA[<p>With mobile devices becoming more and more popular each year, it is about time for the state-of-the-art Web Developer to not only test the sites he is building on a desktop/laptop computer, but also on mobile phones and PDAs. But there are so many out there! Do you need to buy each and every model to be able to test? Well, for a start device emulators can give you a helping hand.</p>
<p>For a couple of years we have heard from experts that using mobile devices for using the Internet will become increasingly popular and will move peoples using habits away from the desktop and into the mobile world. Apart from Japan, this is not quite true yet. Mobile devices such as PDAs, cell phones and pocket computers are getting more and more popular and feature-rich, but it still seems quite tedious to browse web sites on small screens with limited interaction capabilities. <a href="http://apple.com">Apple</a> with its <a href="http://www.apple.com/iphone/">iPhone</a> has done a great job and we can only hope that others will follow in terms of anticipating how users would like to use a mobile device and which features would help them in doing so.</p>
<p>From a developers point of view, it is not only time consuming, but also expensive to consider a fair share of devices out there for testing. Different resolutions, different screen sizes and different browser implementations form a pretty high number of combinations a developer has to cater for. Unless you have a very high budget for testing, this is not gonna be possible.</p>
<p>That is where device emulators and browser simulators come in handy. Luckily for a whole lot of devices out there, software programs exist that replicate the behavior of such a device on your computer screen. Whereas in device simulators you actually are able to navigate and interact with various parts of the underlying operating system (<a href="http://en.wikipedia.org/wiki/Windows_Mobile">Windows Mobile</a>, <a href="http://en.wikipedia.org/wiki/Symbian">Symbian OS</a> etc.), browser simulators provide you just with the interface you most likely will also find on a particular device (e.g. <a href="http://www.blackberry.com/">BlackBerry</a>). </p>
<p>Below you can find a list of emulators and simulators which let you inexpensively test how your site will be displayed on the device. Unfortunately, all of them, except the emulator for the iPhone, can only be installed on Windows.</p>
<h2>Windows Mobile Emulator</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/windows-mobile-50.jpg' alt='Windows Mobile Emulator Screenshot' /></p>
<h3>Installation</h3>
<p>To install the Windows Mobile Emulator, first you need to download and install the following components:</p>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&#038;FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6#filelist">Virtual PC</a> (for network capability)</li>
<li><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=C62D54A5-183A-4A1E-A7E2-CC500ED1F19A&#038;displaylang=en">Emulator with Emulator images</a></li>
</ul>
<h3>Network Configuration</h3>
<p>After installing the two items above, you can find the Emulator Images under Programs > Microsoft Windows Mobile 5.0 Images, which gives you a list of images for different types of devices, e.g. <a href="http://en.wikipedia.org/wiki/Pocketpc">Pocket PC</a>. When selecting one of these images, it fires up the Emulator and loads the respective device image. But before you can use it to test your own site, you need to configure the Network Settings to ensure proper connection to the Internet through your computer. For this, you need to do the following after the device has been booted up the OS:</p>
<ol>
<li>Chose File > Configure > Network in the Emulator Application window</li>
<li>Check &#8220;enable NE2000 PCMCIA network adapter and bind to&#8221; (if you are using the Pocket PC image, it might be different for the other images)</li>
<li>Select your computer&#8217;s network connection card from the list (e.g. Intel PRO) and hit OK</li>
<li>On the (emulated) device itself, locate the &#8220;network card&#8221; settings dialog (on Pocket PC: Settings > Network Card)</li>
<li>Here, select &#8220;connect to: The Internet&#8221;</li>
<li>select &#8220;NE2000 compatible Ethernet driver&#8221;</li>
</ol>
<p>Now you should have a connection to the Internet from the emulated device and can use Internet Explorer on the device to test how your site would look like on e.g. a Pocket PC.</p>
<p>I just noticed that there are more <a href="http://www.microsoft.com/downloads/details.aspx?familyid=A6F6ADAF-12E3-4B2F-A394-356E2C2FB114&#038;displaylang=en">up-to-date version of the emulator</a> and <a href="http://www.microsoft.com/downloads/details.aspx?familyid=38C46AA8-1DD7-426F-A913-4F370A65A582&#038;displaylang=en">device images</a> available from Microsoft. I have not actually installed and tested these, but I am just hoping the installation is as straightforward as with version 1.0 that I used.</p>
<h2>iPhone</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/iphoney.jpg' alt='iPhoney emulator screenshot' />The oh so beloved iPhone also has an emulator on its own, which is called iPhoney. It can easily be <a href="http://www.marketcircle.com/iphoney/">downloaded from marketcircle.com</a> and installed, but only on Mac OS X. The look and feel is pretty nice and neat and it also supports the physical device capability of switching from portrait to landscape mode when rotating the device. In the Web Development circles I heard rumors that iPhoney is, despite the slick look, not providing accurate results and is mere a simple browser window re-sizer than actually providing a correct implementation of the browsing capabilities of the physical device.</p>
<h2 style="clear:both">Opera Mini</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/opera-mini.jpg' alt='Opera Mini Website Screenshot' />Opera has a big market share when it comes to browsers on mobile devices with its <a href="http://www.operamini.com/">Opera Mini</a>. On their site, Opera offers an <a href="http://www.operamini.com/demo/">Opera Mini Demo/Simulator</a> which can be used for testing your Web site. You can even call that site by using a parameter in the URL to call your site straight away, e.g. <span class="code">?url=http://www.klauskomenda.com</span>. Other people have also <a href="http://www.ehow.com/how_2097963_see-web-site-mobile-device.html">had a look</a> at that Simulator and even provided an <a href="http://informatico.altervista.org/netvibes/operamini.php">alternate implementation</a>.</p>
<h2 style="clear:both">Blackberry</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/blackberry.jpg' alt='Blackberry Simulator Screenshot' />You can <a href="http://na.blackberry.com/eng/developers/downloads/simulators.jsp">download one of the many simulators</a> they have on their web site after registering with their developer network. After that, download and installation is pretty straightforward and you can then find the simulator under Programs > Research In Motion > BlackBerry Device Simulators.</p>
<p>The look and feel of the device emulator is pretty great and gives you a good understanding of what capabilities the physical device really has. Unfortunately, I was not able to get a connection to the Internet (from what I have learned you would need to connect to the BlackBerry MDS Connection Service, but how?). So, to keep it short, no testing on BlackBerry. Nice simulator though.</p>
<h2 style="clear:both">ACCESS NetFront</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/netfront.jpg' alt='NetFront Browser Emulator thumbnail' />Another emulator for mobile devices is provided by <a href="http://www.access-company.com/">ACCESS</a>. The ACCESS Netfront browser emulator can be obtained <a href="http://www.access-company.com/products/netfrontsdk/index.html">from their web site</a>, and can be launched by just running the executable from the ZIP archive. Upon launching the application, it took me a couple of minutes to figure out that hitting <kbd>F1</kbd> actually gives you a menu from where you can select &#8220;URL&#8221; and type in the URL of your site.</p>
<h2 style="clear:both">Openwave simulators</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/openwave.jpg' alt='Openwave Browser Screenshot' />From what I have heard, <a href="http://openwave.com/">Openwave</a> is also pretty popular on mobile devices and on their website, they offer a <a href="http://developer.openwave.com/dvl/tools_and_sdk/phone_simulator/">simulator for download</a> (but you need to register before you can do so). I downloaded version 7.0 and I was a bit disappointed by the look and feel and the capabilities it provides. I am not really sure if that is the default or if there are newer versions which can provide more functionality when it comes to rendering Web pages.</p>
<h2 style="clear:both">Nokia simulators</h2>
<p><img class="img-left" src='http://www.klauskomenda.com/wp-content/uploads/2008/03/nokia-mobile-browser-simula.jpg' alt='Nokia Mobile Browser Simulator 4 Screenshot' /><a href="http://www.nokia.com/">Nokia</a>, as one of the leading mobile phone makers, provides a decent selection of <abbr>SDK</abbr>s on their developer network, but unfortunately the device emulators included within these SDKs are built for actual application testing (written in e.g. <a href="http://en.wikipedia.org/wiki/J2me">J2ME</a>) but not for testing Web sites using a mobile browser. So the only simulator I was able to find was the <a href="http://www.forum.nokia.com/info/sw.nokia.com/id/db2c69a2-4066-46ff-81c4-caac8872a7c5/NMB40_install.zip.html">Nokia Mobile Browser Simulator 4.0</a> as part of the <a href="http://www.forum.nokia.com/info/sw.nokia.com/id/d57da811-c7cf-48c8-995f-feb3bea36d11/Nokia_Mobile_Internet_Toolkit_4.1.html">Nokia Mobile Internet Toolkit 4.1</a>. They were made publicly available May 13, 2003 and July 2, 2004&#8230;so not the newest ones, I would say. Before downloading the Browser Simulator, you need to be registered with the Forum Nokia and <a href="http://www.forum.nokia.com/info/sw.nokia.com/id/d57da811-c7cf-48c8-995f-feb3bea36d11/Nokia_Mobile_Internet_Toolkit_4.1.html">request a serial number</a> (in the sidebar, where it says &#8220;Request serial number for:) for the Browser Simulator. </p>
<p>The downloaded package is pretty small and after unzipping it, you can simply run the executable to install it. During installation, it will ask you for your Forum Nokia username and the serial number. After the installation, you can find the simulator under Programs > Nokia. The simulator itself is pretty disappointing cause it offers an interface with fits to the date of publication of the simulator and, more importantly, I was again not able to connect to the Internet. All I would wish for is that Nokia would update their standalone simulator to the newest models as soon as possible.</p>
<p>I just <a href="http://www.forum.nokia.com/main/resources/technologies/browsing/tools_for_mobile_web_developers.html">learned on their Forum</a>, that the emulators provided with the SDKs actually provide full device capability, but I have not had the time yet to download one of these bundles and check for myself. SDKs are available, e.g. for Java (<a href="http://developer.nokia.com/info/sw.nokia.com/id/449a2f84-2a8a-44fa-a7f4-93b53cb9c89a/Series_80_Platform_SDK_s_for_Symbian_OS_for_Java.html">Series 80</a> and <a href="http://developer.nokia.com/info/sw.nokia.com/id/6e772b17-604b-4081-999c-31f1f0dc2dbb/S60_Platform_SDKs_for_Symbian_OS_for_Java.html">Series 60</a>).</p>
<h2>Further reading</h2>
<ul>
<li><a href="http://www.howtocreate.co.uk/tutorials/css/mediatypes">CSS tutorial on Media types</a></li>
<li><a href="http://www.webcredible.co.uk/user-friendly-resources/web-usability/mobile-guidelines.shtml">7 usability guidelines for websites on mobile devices</a></li>
<li><a href="http://www.thinkvitamin.com/features/css/make-your-site-mobile-friendly">Make your site mobile friendly</a></li>
<li><a href="http://www.uservision.co.uk/resources/articles/2005/usable-web-pages-mobile-devices/">Usable web pages for mobile devices</a></li>
<li><a href="http://ready.mobi/launch.jsp?locale=en_EN">ready.mobi</a> (a tool for testing the mobile-readiness of web sites)</li>
<li><a href="http://mobilewebbook.com/">Mobile Web Book</a> (book by <a href="http://cameronmoll.com/">Cameron Moll</a>)</li>
<li><a href="https://www.sdn.sap.com/irj/sdn/nw-wdjava?rid=/library/uuid/32c0278c-0901-0010-e0ae-9806236443f3">How to Install BlackBerry Simulator, Pocket PC Simulator, and Nokia Emulator</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.klauskomenda.com/archives/2008/03/17/testing-on-mobile-devices-using-emulators/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

