Sometimes a good regime creates a friendly environment for development.

By this I mean that rules forced in an operating system for the programmers should make it obvious how to code and how not to code. Apple for instance set very clear rules on running applications in the background (no applications in the background!), but also gave developers innovative push notifications. Android often follows with those innovations in the design of the Android API, but still leaves a lot of open space for doing things in the wrong way. The once famous quote by Magnus Lycka “It seems to me that Java is designed to make it difficult for programmers to write bad code, while Python is designed to make it easy to write good code.” is turning away from the former language even more, once Java became an interface for programming a wide area of system services and applications in Android.

I’ve met many people puzzled by the way android Activities work, especially when it comes to construction, destruction, and even things as simple as rotation (that involves destruction and re-construction of these objects). The simple answer is: never expect your activities to be there, like “Nobody expects the Spanish inquisition” in Monty Python’s sketches.

* If you’re an advanced Android developer, I’ll save you reading about the Activities, so click through to go to the juicy part of this article

While developers can decide how activities are launched in tasks, their construction and destruction is managed by system and they might be often left in one of the intermediate states, where they are not visible or probably about to shut down (see more about it in the Android Developers documentation).

The example is when we receive the phone call while browsing the application, the phone app comes to the foreground, and depending on the memory conditions, the application might even be shut down in the background (although it doesn’t have to). When we hang up the call, we expect to come back to the application without losing any introduced data. This data is often not in any permanent storage, but still in the UI (UI components like edit boxes, and additionally member variables). If not saved properly in the onSaveInstanceState() and restored in onCreate(savedInstanceState) or onNewIntent(savedInstanceState), these temporary changes might disappear.

As I mentioned previously, rotating the screen has the same effect on the Activities life-cycle, like if it was kicked out because of the lack of memory. It goes down all the way to the onDestroy() and gets recreated again. Developers often prevent it by allowing only vertical orientation of the application or even creating static member fields in the activity. This covers only half of the problem, and it’s more of a hack than the permanent solution. Member variables should be serialized using the Parcelable interface when activity requests that.

There are some objects that can’t be treated that way, i.e. background tasks. It’s a bad practice to re-instantiate the task when the activity got re-created. Just imagine fetching a large image file multiple times. There are two solutions for this problem. One is using the retainNonConfigurationInstance() request from the Activity, which returns the object that shall not be destroyed while activity is about to be recreated (although this approach has been deprecated in favour of the new ActivityFragment architecture). Another solution is to use Service to maintain long-running tasks in the background.

Well, all this information above could be surprising for the Android newbie. But there is another case of writing a quick but problematic one-line code that caught my eye recently.

Android doesn’t help developers handle remote image content easily. It requires quite a lot of code to transparently load images from either URL or the local content provider or the file stored somewhere on the file system. It would be nice yet if it was cached in the memory so we don’t have to reload it from either source each time. And the cache could have a limit depending on the device capabilities. And the CPU load should be optimised to let the more important content appear on the screen first. We’ve seen it all work somewhere, whether it’s a browser app, Gmail or twitter. Images are loaded smoothly while we browse the content.

Koushik Dutta created a great library for caching images from remote sources (whether they’re on the internet or just somewhere behind the content:// provider) and made it very flexible, so one can make it work right away with a very little effort but also use it in a bit more complex way. At the same time, the example provided with the app shows a very improper use of it’s own library. The activity fetches a JSON feed of images from Google, using the phrase provided by the user. Then it passes a list of URLs to the adapter and starts loading them.

Right, this magically (almost) works, because adding each element to the list causes an obscure notifyDataSetChanged() call in the adapter and all list elements get redrawn. Some images might not get drawn in the right place though, but it will be hard to see in such a long list which we will be scrolling up and down, until all images are loaded…

Why is that? Adapters recycle list view entries as long as it’s possible (see convertView in the getView method), so the reference to the imageView will be the same across all the list. If we try to load images in all the entries, we will initialize the downloading in the right place, but when the result arrives ready to draw, only the last element in the list will be updated. Other list entries are only “dead” copies of the convertView (probably drawn to the canvas only once).

What would the solution be? Well there is one, already in the library. The method setUrlDrawable is overloaded with a bunch of different arguments. The one would be:

with the imageView set to null and callback set to the calling activity that would implement the onLoaded method with calling mAdapter.notifyDataSetChanged();

But remember about the activity construction and destruction, huh? What will happen to the orphaned tasks when we recreate the activity? How do we re-attach the observer to the tasks when needed?

I’ve created my own library that fetches images from the internet and content providers, and there I propose how to use it with the activities in the example. It forces the right coding style for refreshing the on-screen content by using the observer/callback pattern instead of holding the references to the views that might get invalidated with other data in the meantime. Please take look at the library and use it. And tell your fellow programmers to try it too. I welcome all comments. There’s surely room for improvement, but it might surprise you nicely with it’s functionality. And I hope the way it is designed helps understanding how it works.https://github.com/mobiosis/images-androidhttps://play.google.com/store/apps/details?id=com.mobiosis.imagesexample

I would also prefer the android Lint to help developers design code in the way it is more error-proof in the areas of object instance management. This part that is likely forgotten by developers with non-C experience (hello GarbageCollector). Although completely correct, this kind of code gives me a bit of a headache:

But when used in a recursive call becomes a really big pain, as mentioned above. It is cool to create instances on the spot, but putting extra effort to keep track of them has actually more value.

Other than that, Java is a really cool language (especially in Android). One thing I learned at the beginning of my experience with Android programming was: when there’s a problem, there must be some solution. This comic illustrates it quite well.

PD. Anyway, thanks to Koushik Dutta for creating a really great piece of code. I don’t try minimise it’s value. It is a very useful library, although I got to know about it very recently, so I created something apart.

Also thanks to Oriol Jimenez for his very inspirational presentation at GDG DevFest in Barcelona and DroidconES in Murcia later this year. You can find more good advices there (if you understand Spanish).

All sums up to roughly 20GB. This is a lot of a wasted storage space for laptops with SSD drives, whose capacity is often around 120GB.
And this information is hidden in the System Drive (c:\) -> Properties -> Disk Cleanup -> Clean up System Files.
I’d expect to find it in the context menu for Recycle Bin or alternatively Add Programs and Features/Uninstall a Program area (that’s where I will search to free some space on my computer by default!). It’s hard to think where to find this cleanup option after using modern smartphone OSes. Even after years of using Microsoft operating systems this seems very counter-intuitive.

Almost two years ago Intel aproached developers in Barcelona with the mysterious tablet called ExoPC and very early version of MeeGo operating system. Some lucky developers walked out with the device and were able to start hacking on this touch screen enabled netbook tablet (indeed this device is powered by the Intel Atom x86 processor which used to be the heart of Netbooks). It was not very convenient to use, because MeeGo operating system never reached its maturity and was abandoned. There was no viable alternative for a long time. One could install Ubuntu or Windows 7 but those operating systems were not well prepared for operating without keyboard or mouse.

ExoPC running Windows 8

There surely was a place for Atom powered x86 tablets in the market and I never gave up on this device. Some new opportunities emerged soon. While most people are abandoning netbooks today, ExoPC still resists this trend, mainly because of two reasons: touchscreen, more than average resolution of 1366 x 768 pixels and a decent 2GB of RAM. Two new (or heavily refreshed) operating systems appeared as an alternative OS for this device: Android 4 and Windows 8.

Android, starting with Ice Cream Sandwich version (4.0) offers an interface optimised for phones and tables without additional hardware buttons (like Home, Back, Menu, Search, etc.) and was also released as a source code. This let developers build custom ROMs and some older devices with unlocked bootloaders (i.e. Samsung Galaxy S, Nokia N900) got their more or less working version of the new Google operating system. The important step in this case was the release of the Android Atom x86 optimised image by Intel, allowing better integration of Android software for developers. As a non-expert in ROM cooking I cannot really tell if this image could help the Android X86 project, but it would be quite logical to assume so.

Downloadable Android x86 Atom optimised images

Meanwhile, before anyone in the broader public got to know that Microsoft is cooking it’s own tablet, the Redmond company started commercialising the well known ExoPC as an early Windows 8 developer device. It is still a cheap and viable alternative for the Microsoft Surface. The advantage over the current version of the MS Slate is that ExoPC runs the full version of Windows 8 (Not the Windows RT), which allows you to use all the apps compatible with the previous edition of the Windows OS. The downside is that the ExoPC slate might not be fully compatible with the future Windows 8 apps.

ExoPC in the aftermarket

It supports multi-touch, but only with 2 touch points, while the new system might require as much as 5 touch points. Windows 8 also aims at devices that can normally do much more than the PC used to do. There are plenty of sensors that help Smartphones be very useful in everyday life and will be (or already are) a part of Windows-8 compatible devices.

But the best part comes here. Even if you have installed Windows 8 on the ExoPC, you can still use it as an Android device. And this is something much better than BlueStacks implementation of the Android OS, which might not always be up to date, but especially will not give you the full Android experience.

So you can install the Android 4.0 on this device, preserving the current Windows installation. This is quite simple process which you can do in a couple of steps described in this thread (in German).

If you’re not familiar with German or cannot understand what Google Translate provides you, do this:

You will need to connect a keyboard to pass through this step (sic!), but it’s actually better to have it connected already at boot to avoid funny effect on the console screen.

Choose to install GRUB

When it asks if to add the Windows partition to the bootloader, select yes

Install the system in the R/W mode

You can restart and begin using Android (isn’t that great!?). Well, until you find some issues. There aren’t many, but depending on how you use Android, they might be a bit painful. A list of a few of them below.

Bootloader

Linux’s Grub will overwrite Windows Bootloader. You will still be able to start both systems, but all the functionality of the Windows 8 bootloader (changing driver signing, safe mode, etc.) will not be available. That might be a bit of a deal, but if you installed Windows 8 on top of Windows 7, then probably you will see the old text-based bootloader that was installed on the partition instead of MBR. If you restore the Windows 8 bootloader in the MBR, you will not be able to launch Android. There should be some way to do it manipulating the startup items (I recommend EasyBCD) but I had no luck in this matter.

The power/sleep button

Sometimes it’s difficult to wake up the device when it went to sleep. From my experience it starts behaving normally after prompting the “Power-off” dialog. To show it, “double-click” the power button.

Battery

The battery life is not astonishing. Because the device warms up significantly, independently of the usage, I suspect the CPU scaling is not very well supported. It doesn’t seem to take advantage of the “sleep” or “suspend” state, so it’s better to turn it off while not using. It might also happen that the system will not report the current battery state (it might stall at the initial value) so you might suddenly run out of battery (this is quite obvious though). This issue only happened two or three times for me. Restarting the device fixes it.

Apps

Not all apps will be available for this version of android, especially those which use android NDK (unlike Java, this the C++ part of code that is only suitable to the CPU architecture chosen at the compile time). The examples are many games, Skype, and whatever software that makes a high use of processing power.

To address this last issue, there is a version of the ExoPC ICS, with the built-in ARM emulator (the CPU architecture used in most Android smartphones). It is still in the experimental phase, but after a half-an-hour test seems to work good for me (download ISO here). There are still some apps that will not run (probably other requirement stated in the app manifest) but even without those few missing apps ExoPC slate is now a very versatile device that can be used as a testing device for programmers, or a “couch leisure centre”.

I’ve been an enthusiast of alternative software solutions since the beginning of PC era, where Microsoft software, although dominating, wasn’t the only right path. Since mobile phones became smartphones, I also expected them to be modular and configurable in areas of user preference, so I welcome the possibility of exchanging the system default application by the one offered by 3rd parties. This is not common feature among all the smartphone OS-es but highly desirable where user has some non-standard requirements.

I for instance like browsing internet using Opera Mobile which gives me unified experience among many platforms, synchronizes links, saves the mobile data usage. The same situation happens with Swype keyboard, which supports my native Polish language with error correction. There are more good examples but I get puzzled with the complexity of this approach sometimes, and even as an Android developer, I cannot understand options that the system gives to me.

Case I: Web Browsing

I’ve installed Opera and Firefox browsers on my Android phone. The reason for installing the first one was explained above. The latter was convenient because of the Firefox Sync feature which lets me access my PC browser data transparently. I still might try another one as none of the browsers above allow me to preload a few pages in the background, while browsing twitter or news from my email. I often try to achieve it, but usually the system closes browser in the background and I need to load pages again, what is very frustrating if I’m in a place with low network coverage.

Back to the point. I click the link in my Slashdot newsletter and the well known pop-up appears.

Choose your favorite browser

I want to use the Android browser by default, so I mark the “Use by default” box and choose the first browser. The browser window opens and exactly the same dialog pops up for the second time. Strange right? This might look like an error to an average user but as a developer I know there are various “Intents” that open the browser (called “action” in the window above). I repeat my choice and the web page loads in the browser. The same will happen later when opening some Youtube link, Doodle, Twitter, etc. At some point it might become annoying, because if you have installed some application to handle certain content better than the browser, then why all those questions?

In the PC world some similar mechanism exists although it is more file-centered than action centered. When you are installing a new Video or Image application, you can choose during the installation process if it should be associated with the certain file types (unless it’s a bad application that forces you to use it with some files). This mechanism was field-tested over many years and proved to be very successful. Since Android OS knows what a certain application can do while installing it, maybe it would be a good idea to ask the user at this point. This would not require any changes in already published applications. It could be much better than showing dialogs which are often meaningless if the “action” context is not clear.

Said that, I’d also appreciate to be able to choose the application again in some situations (like browsing with Opera when I only have access to 2G network). This is not possible unless developers explicitly create the chooser for the action (using Intent.createChooser).

Case II: Contacts

I’ve installed some additional programs for handling my contacts data. One of them Everdroid (SyncML service, known to me previously as Mobical) for synchronising my Contacts and Calendar data (that worked great Nokia many phones for at least 8 years), and another Go Contacts replacement for my contacts book so I could merge duplicates easily. Here’s what happened when I wanted to add a new contact to my address book.

System prompted me to choose a program which will manage this contact. Not sure what to do, I’ve chosen the the default app. Then the system asks me which email account do I want to add it to (3 email accounts present on my phone). I was confused, decided to go back.

Choose your account to add a contact

I’ve tried the same with Contacts Go and it shows me 3 accounts from above plus a “Phone” as a last option, just like if I was suffering from the lack of choice.

I’ve chosen Everdroid now and it asks me again if I want to add it as an Everdroid contact or Google contact.

That seemed pretty complex already with the default app so I’ve decided to uninstall the additional programs to avoid confusion. Unfortunately all the contacts downloaded from SyncML server with Everdroid got deleted with it. Surprised?

There are plenty of services that maintain their own lists of contacts as Skype, Facebook. Twitter, etc… On some phones they might even be listed together with other contacts in a unified form and be deleted when you get rid of a certain account or application. But I’m more keen to believe this is fair in case of Facebook. Twitter, Skype, as they also provide some service or content, which becomes the platform for communication. If I create a contact in my phone book (or maybe better “contacts book”), I want it to persist there, unless I decide to delete it one day, not the application who created it.

As a result I stopped using additional contact management tools, and finally agreed to use my Gmail area for managing all the permanent contacts. Apart from Android, this also works flawlessly on iPhone and even on older Nokia phones (using MS Exchange server settings for Gmail).

In areas where data is sensitive, it’s sometimes better to trust the provider of your device/OS and try to dig in the possible options of default applications before switching to 3rd party solutions. Replacement applications might be very rewarding if you choose them wisely, but if you’re less lucky, you might just add another unnecessary layer of problems and complications.

This is a bit off the mobile software and programming topic, but still something for those who like gadgets. Last Christmas my dad, very thoughtful of me, decided to get me a decent digital camera. Photography has been a great hobby throughout his life. In the mid 80’s he even opened a photographic studio and maintained it for almost 10 years until we moved to another city, which closed this adventurous period.

Even until now there are plenty of cameras in my parents’ house. Two Pentacons, Practica, Zenit, my first camera Smena-8, my favourite Yashica FX-3 and some unique vintage cameras. But among all of them my dad has always had a special feeling for Nikon as a high quality, innovative brand. One of his last buys as a professional photographer was the very automatized at the time Nikon F-90 with state of the art SB-25 flash. This set provided him quite a lot of fun and also plenty of quality photographs.

I don’t spend a lot of time photographing, so I wouldn’t need best featured camera. My preference was actually towards compact ones that I could always have with me in my jacket or in a small travel bag. We came to the conclusion that the camera would be a compact one with advanced features where I could manually adjust exposition time and aperture apart from what’s present in most cameras. There were a few models that we were taking into account but I let my dad make the final choice and make it be a surprise. I had a feeling what he could choose and it was Nikon.

Indeed he chose Nikon, model P7000. This is a very powerful device and the quality of photographs is very high. Sometimes the plenitude of adjustment options leaves me a little lost but I get to take photos I like so it’s definitely something I wanted to have. Unfortunately after a few months and a few hundred of photos taken the lens stopped working properly. Even though I always kept it in the protective Hama bag, and never exposed it to hazardous conditions, the lens started buzzing while moving and very often the lens cover didn’t open properly cropping many of my pictures in an ugly way.

The camera was bought in a store in Poland and has a European-wide warranty so I decided to take it for repair to the official Nikon service in Barcelona where I live. This took a while to get it there because the service was closed for holidays in August (very common in Spain), and then it had a plenty of repairs pending in September (that would cause over a month delay) so I decided to come back in October.

Apparently servicing the camera with the European Warranty Card, stamped and signed by the store where my dad bought it in Poland, with the date, model and device serial number was not so obvious. The official conditions for servicing the Nikon camera was to bring the warranty card together with a purchase document. I guess it was to confirm the date and legality of the purchase. This was obviously already on the warranty mentioned above, which I explained patiently to the service assistants, but they didn’t let it cover the repair. I explained them that my dad got it for me as a Christmas present last year, so I wouldn’t have the shop ticket included in my gift box for obvious reasons. Instead the warranty document was filled in with all the data the service shop would need to repair it. Again, no success.

The European Service Warranty card that was not sufficient to fix the camera.

I didn’t expect my parents to find this ticket easily, knowing they handed me the camera with the document, sufficient in their eyes, to repair it in any case. They did search for it once, with no success. I contacted the Nikon website but they couldn’t provide me any help as the service shop was decisive in terms of the validity of repairs. The store in Poland couldn’t provide me a copy of the ticket as it was the simple ticket, not the invoice that they would have to maintain in their documents. So the last chance was to bring it back to Poland where they would accept the local warranty card and leave it for my next two visits there. Or I could cover the cost of P&P for the international package twice and also wait long. While viable, both solutions were simply inconvenient knowing that I have a camera covered with the European warranty.

This very simple ticket that could hardly be a legal document was necessary to repair a camera.

Finally my parents found the ticket last week, and the service shop in Barcelona accepted the camera for the repair under the warranty. Luckily, because this warranty lasts only one year, and is valid until 11 of December. Although this is a happy ending to the issue that was bothering me a bit over the past few months, it left me a mixed feeling about the Nikon brand. Knowing for example how Nokia handles their repairs in Europe, where you just bring the device without any document and they check it by the IMEI in the database to confirm if the warranty still covers the repair, it just made me feel disappointed. Is it the bureaucracy straight from Kafka’s novels or the fact that some companies might complicate their laws enough to reduce the costs of handling repairs at the price of the customer satisfaction? At the same time they’re making an advertisement about the European (or whatever scope) wide warranty.

This might sound like my very own issue since I live in a different country than my parents, but maybe more people do the same in the age of online second-hand shopping, product search aggregators, unified trade laws in European Union and a common currency (or the easiness of money exchange in online transactions). If I bought the camera from the United States, Hong-Kong or any other place where electronic gadgets tend to be much cheaper (although not so cheap if you have to pay customs when you receive them…) I could expect these type of problems. But this was not the case.

It might be worth to take a fresh look at the brands whose value is often taken for granted. While searching for the best features and a good deal it might be too much to perform the search on the warranty handling at the same time. Maybe betting on a good word put by someone who had the similar experience would be enough to add to the credibility of the brand. I would welcome comments if someone could share experiences here. The Christmas shopping madness will get to its peak soon, and it might make us more prone to making a similar mistakes when the time is running and stocks are going down.

Heavy clouds seem to have been hanging over the Symbian platform since February 11 this year, when the new CEO Stephen Elop announced that Nokia has chosen Windows Phone for its devices as the main operating system in the future. It was obvious for some that Symbian’s, as well as Qt’s end have been called. Although, Nokia still claimed that it’s formerly dominant platform will still be evolving and the Qt platform will be there.

I’ve lost my job as a Symbian developer at the beginning of the year, and I was wondering if there’s a place for a Symbian/Qt developer in the market yet. I’ve trusted Nokia’s promises. I’ve decided to continue with the Qt framework for development. I’ve been attending events that gathered people interested in that technology (starting in 2009 with the Meego long weekend Barcelona, followed by the Symbian Exchange and Exposition in 2009 and 2010, volunteered at Symbian stand at MWC in 2010, attended Nokia Dev Day at MWC 2011, Qt labs in Madrid in April this year, Intel AppUp labs for Meego in February and June), I’ve been observing trends in freelance projects (www.elance.com) and yet trying to search for opportunities locally. Unfortunately all of these intents (robotic laugh here) were unsuccessful. Some of the clients I’ve talked to were very interested in Qt development at the beginning (March-June) but soon they all changed their decisions to go away from native development towards HTML5 or simply drop the Symbian project as not worth the investment. By the end of August there were virtually no signs of interest in Symbian/Qt development.

In the meantime I was still working on my own projects for the Ovi Store (BiCitizen , Siberdrome, Solitarius) so I didn’t just lose my time thinking of the wasted opportunities. Although, it was obvious that at some point I will have to move elsewhere as the promises of Qt for the next billion were too vague. Having in mind previous Nokia’s promises about Qt, I guess it was not worth wasting the time to wait for another market opportunity. Now, that even Intel moved away from the Qt platform with Tizen, please raise your hands up, who are still planning the mobile Qt project soon.

I must say I’ve achieved something more than decent in the Ovi Store. “Solitarius” game has been downloaded more than 350.000 times in over 200 countries and other game, “Siberdrome” (only Symbian^3) almost 30.000 in last 3 months. But If I see similar games on the Android Market, (i.e. this Solitaire game) which achieved over 10 million downloads, it’s just hard to compare the range of success.

Nokia World event is approaching so we can expect the appearance of the Nokia Windows Phone, but is the Windows Phone the best direction for the Symbian/Qt developers?

I’ve worked with Symbian C++ since 2006. At first using the Visual Studio but then the Carbide/Eclipse environment since it was enough stable to be usable (which dates back to 2007) and finally accustomed myself to it’s flexibility and extensibility. Qt SDK came with the custom IDE that couldn’t be compared to any other IDE with which I’ve worked with so far. Although fast and well designed, it was sometimes inconvenient. Qt APIs are great on the other hand so I couldn’t complain too much about developing with the formerly-Trolltech’s SDK. It was a huge step forward from the obsolete Symbian C++ environment.

Having all this baggage I’ve brought with me from Nokia, I’ve decided to step away from it and started the Android development. This is probably obvious for those who did the same, but what a relief it was to come back to this great open-source Eclipse IDE. How nice to see many APIs and classes resemble those from Qt, and have those XML layouts which are not so far from Qt layouts and Qt-Quick. Already at the beginning I felt like I’m one leg in the Android ecosystem. Being able to quickly compile and package multi-language application with support for multiple resolutions and well-defined backwards compatibility, I was so happy I almost peed in my pants*… I wonder if heads of Nokia thought about this convenience for a while, while deciding to make a change of environment for the developers. Maybe the biggest enemy was actually a close friend here.

I’ve never taken Nokia’s decisions personally and was never angry at the changes in their plans and shifts of strategy. While living in Spain, I’ve watched how Spanish government had to make serious cuts in the public sector recently to save the country’s economy. Having seen the movement of “Indignados”, protesting against decisions of the government, sometimes in a very inappropriate way, I’ve decided it’s just a wrong to outrage. Showing that you can live well to someone who put you in a very difficult situation is much healthier response than revenge.

At the moment, that’s for sure, none of my friends wants a Symbian smartphone anymore. One of them who went to a few stores to get advices on smartphones recently, heard from sellers to get out of Symbian (not to mention allusions to the human waste). Those I know still choose other brands in spite of the reasonable effort I put to tell them something good about Nokias. My girlfriend is a great example here. She got two of her pictures into the www.nokiacreative.com contest for August. People are impressed with the quality of the N8’s pictures, but they get put off when they hear the “S” word.

This way I’ve joined the club of the green mushroom-like avatars, waving my hand to the new world. I don’t say goodbye to Nokia forever. Maybe we will cross our paths in the future. Maybe I will actually use one of the technologies they develop. But even now, eight months after the February 11 announcement I’m still confused which development platform they try to focus on. Is it Windows Phone? Is it Qt? Is it S40 with J2ME?

The new programming framework QtQuick (or QML when referring to a language) developed and supported by Nokia is as much of a challenge as an opportunity for the mobile phone programmers.

Learning new programming languages might be as difficult as learning the language spoken by the tongue. To the contrary, learning the spoken language might be also easy and pleasant, so there’s no reason to approach this challenge as an obstacle.

Been here before.

Having learnt a few programming languages in the past (C, C++, MFC, Symbian C++, Matlab, Bash scripting, etc.) and now working with Qt, but also a few spoken languages (Polish, English, Spanish, and bits of German, Russian and Catalan) I try to remember where the learning was difficult and where it went like a charm. Let me tell you a story how it went with a few spoken languages.

Hello (World)!

The first foreign language I got in touch with was obviously English, as the political switch Poland experienced at the end of the 80’s and the beginning of the 90’s turned the pop culture upside-down. I guess many public schools were not prepared to this new situation, and the teachers were going the very obsolete path read-conjugate-memorize. That was a very painful road to learning the language, and if there was no Nirvana, Jim Carrey, The Simpsons and at last (but not least) Jerry Seinfeld, I’d probably never become fluent in this language.

Hier kommt die Sonne.

Then at some later stage I started learning German. Because living close to the west border of Poland has always been marked by the strong international connections (and remembering the words of grandfathers to “know the language of your enemy” 😉 ). Hopefully the pop-culture was helpful too. The chart-buster Rammstein music or movies like “Run Lola, Run” or “Goodbye Lenin” were always a good training field, and gave an emotional boost. So after a year of learning in a private school I went for holidays to a “Bizarre” music festival in the west of Germany and discovered I can already communicate! Even the basic set of language skills could be an effective tool for communication.

Excuse Señor, no speaking Inglese

Then one day I decided to go to Spain, Almeria for the student exchange and apparently I had no knowledge of Spanish. This was again a different family of languages, so it was not only about learning few irregular verbs and communicating in a funny manner but with almost no initial effort. I had to learn everything from the “Hola”. So the first approaches were not very easy. I went to a quick course of the language at the university, but left with a sensation of a lost time, as I almost didn’t pick up anything from it. But I started learning something about the place where I will go and that caught my attention. Getting to know something about the history of southern Spain (Andalucia) woke up my imagination of the place. Then I started a self-learning course for listening, where I had to repeat phrases from a quasi-real situations a few times during each lesson. This role-playing worked quite well, as after only 1 month of this course I was able to deal with random situations like i.e. to buy a ticket at the bus from the airport in Almeria. Then everything started to play in sync, when I was chatting or being chatted up at a nearby coffee place, park, etc… After 5 months spent there I was an effective communicator with a good writing and speaking skills.

How do you say “Hello” in this new language?

So how does it match learning Qt Quick, you may ask. Where’s the connection?

Learning programming language is in general easier task than learning the spoken language. If you know one, especially C-like language, you will find yourself easily around others. Those relations can be similar to a family of languages. It’s like learning Spanish for Italians, Dutch for Germans, Russian for Poles (or British English for Americans)… Qt Quick is more than that. Besides the Qt environment that is very much like C++, there’s also a UI layer defined in QML. I can assume every programmer had some experience with either XML or HTML and maybe knows a bit of JavaScript.

It might be difficult if you don’t know what to do with the new environment. Where to start, where to pick up, which way to go? Very important parts of learning this new environment are similar to the ones that make learning spoken languages successful. But Qt Quick is settled on some very strong pillars, which will be helpful for a programmer during all the development journey.

Four riders of the apocalypse Qt revolution.

Who are they? Where do they come from? There’s no problem figuring out where Qt started. It’s a company called Trolltech being a part of Nokia now. Why is it so good for developers? Here are the reasons.

One is to know what has been done with it already. Qt has a 15-year long history of successful appliances in technology, entertainment and everyday-use devices. Big money and fame has already proved to have the Qt frameworks planted back in the garden. Nokia has already over 75million Qt-capable devices in the field and will continue to support the Qt development. Intel will continue developing MeeGo and will also support the Qt technology with their fantastic tools.

The next is what can you do with it as a programmer? Browse one of the open-source Nokia Projects, or Qt-Labs repositories, download them, play with them, modify them, do something new based on them! That’s so easy when you can see the real and functional app that’s open source. Then publish the app in the Ovi Store, or Intel AppUp store. If that’s not enough, see where else you could go with Qt. That gives myriads of opportunities.

Further one is the community here. You won’t be lost between examples, videos and download links. There’s an active and supporting community forum.nokia.com which is always available for you to help. I’ve been a part of that community for over 4 years now, and I have been very content with how it works. It’s like being in that coffee place or a park where people start talking to you, so the foreign land becomes your own.

And finally when you already know what to do, reach out for books. The recently announced book “Beginning Nokia Apps Development: Qt and HTML5…” is a perfect companion for the day-to-day development. And the F1 key should never be undervalued when working with the Qt Creator.

“Punk is (not) dead” was also a big hit since the early 1980’s.

Now one last word. I’ve seen many blog and twitter entries about “Symbian is dead” (or will be soon) and “Qt has no future” (because Microsoft tools are the future target). As I’ve been living in Barcelona, it reminds me of the case of the Catalan language. Many discuss the viability of this language vs. Spanish which is dominating globally. While we are a part of the global environment, we live in the local environment. The local environment will always have the advantage, because that’s how people are. Analogically, Qt and Symbian are “here and now”. They are very strong and growing. So global marketing of other platforms cannot change this. We will speak QML here.

Recently updated QML projects showcase encouraged me to start learning more about QML. Two examples gathered my attention especially. The first of them is the Bubble Level application which uses the accelerometer reading to provide a leveling tool, and another a really cool game called Quick Hit.

As the latter has rather complicated structure with animations, multiple windows and plugins, I’ve left it for ‘dinner’ and started looking into the leveling app. I first looked into the “BubbleLevel.qml” file which was indicated as the UI starting point. The structure of the UI is very simple and I’ve found myself quickly around the controls’ definitions. Most of them have the typical height/width/anchors/margins attributes for quick UI creation. Additional features include function call on the event like:

onClicked: bubbleLevel.minimizeApplication()

where “minimizeApplication()” is the public SLOT in the app definition, so binding the QML UI with CPP functionality is extremely easy.

One of the puzzling elements was the definition of some UI elements. Some of them like “Image”, “MouseArea” or “Flipable” are already defined in the framework, others are defined in a separate file provided by the application like “Tube” and “Button”. It seems that the name of the control is taken directly from the qml file name so the Tube is defined in the Tube.xml file and Button in the Button.xml file respectively.

While there’s a lot more to learn about the UI in this app, I thought to extend it’s functionality to ^2, by adding the second dimension to the bubble movement. So in the first place I created/modified the graphic resources to support the second dimension. These include:

air bubble (is more or less round now)

tube (now became something like a football pitch)

vertical shadow

vertical scale

Notice that new files need to be added to the .qrc resource file.

To support the new dimension I had to look into the C++ code where the accelerometers readings are fetched. The function provides already 3 readings, so I didn’t have to modify it, just add the “y” dimension to the rotationChanged signal (now watch out, in case of Maemo the “y” axis has to be inverted to work in the same manner as the “x” axis; for Symbian it’s yet to be checked, as I couldn’t install the Qt 4.7.1 on my test phone yet). This started a chain of inconsistencies, as the SLOT connected to this signal needs to be changed. These connections are defined in the main.cpp file so tracking them down didn’t cause much trouble. There were also two functions from the settings.h which needed another argument, and these are saveCorrectionAngle and correctionAngle.

When the application was already compiling I launched it and of course didn’t work yet, because the necessary QML bindings were not defined for the second dimension. Moreover the bubble stopped moving as the functions were not compatible anymore. Luckily running the application in the Qt Simulator or from the Shell Console on Nokia N900 you can see the debugging messages. In this case they helped to localize the mistaken bindings.

Now a bit more (but still not too much) work was needed to modify the Tube behavior. When the new readings are set to the tube, only the item’s property rawangleX/Y change and the position is updated automatically. With the new dimension, we had to add the new function to calculate the variation of the bubble from the center of the tube. The original behavior was to reach the limit of the tube every 20 degrees horizontally (this was defined in a bit obscure way; the order of “/” and “*” operations was hard to guess), so we I did the same for the vertical axis.

The final refinements included changing buttons anchors

top: parent.top
//verticalCenter: horTube.verticalCenter

and changing the tube’s height to the actual proportions occupied on the background image

width: parent.width * 0.775; height: parent.height * 275/480

There was a problem running the example on Symbian phone due to unavailability of the qt libraries (also qt_installer.sis from the SDK failed for some security reason) but let’s hope this get fixed in the nearby future.

qtbubblelevel_2D-src.zip (source code)
As you can see, there’s also an extra package for MeeGo device. It’s neither compliant with the Intel AppUp specification nor fully functional (the bubble doesn’t move but it’s hard to say why at this stage). But the package can be installed properly, the icon is available on the desktop, and all the QML is rendered as expected.

So these were the only changes needed to have the working 2D example. I must say that’s much cooler to show to a friend in a pub and to test his/hers ability to level properly after a pint 😉
But also imagine you can now apply this example to the game for steering.

I’ve spent the Tuesday morning two weeks ago volunteering in the ideas.symbian.org lounge at the Mobile World Congress in Barcelona. The place, full of soft pouffes, maintained in yellow-white-black design, and also decorated with huge bath-ducks (that’s a Symbian’s mascot these days) attracted many business people, who either wanted to rest for a while with a tasty-yet-free coffee (the bartender didn’t share recipes, so no open-source here, Symbian 😉 ), have a little chat in this quieter place, or just use the free WiFi access.

Having an opportunity to talk to some of them I tried to inquire for ideas they could share with Symbian to improve future devices and our experience with more and more capable smartphones. That’s no surprise that among people who visited the lounge many used Symbian (and in particular Nokia) phones for a while, but abandoned them for the sake of BlackBerries or iPhones. The very common words repeated in these talks were that these competitors bring speed, simplicity of the software (watch the huge scrolling menus) and intuitiveness (shall I mention kinetic scrolling yet?).

There were of course some hardcore Symbian users or partners, who had very precise ideas what they need from the platform, and knowing where it’s going they just wanted to take advantage of the new business opportunity.

Someone mentioned he would like to have Symbian extensible for embedded platforms. I imagine he could use it for his own brand coffee machine, radio or something else yet (i.e. have you seen the QT-based coffee machine? http://twitpic.com/l8yzz).

Other idea was referring to more flexible software payment framework. The developer could charge for the software usage rather than for downloading it from the Ovi store (that would boost the number of freeware applications, and let the user choose more wisely, depending on how they actually like the application, instead of a quasi-blind shoot, based on the last comments, description and a couple of screen shots…).

There was also some interesting vote from the person who actually worked with Nokia, and couldn’t understand why there is no profile scheduler anymore (that’s something that sets your phone to silent automatically everyday from 10pm to 7am). I was able to help with the software I used in the past (feel free to try it yourself at http://www.drjukka.com/ ). And that’s good that Symbian allows the independent developers build additional features, but I don’t see any reason why the top-shelf phone like Nokia N97 shouldn’t come up with that feature built in! I remember this was available in Nokia DC4 business phones like 8310 or 6310i. OK, for now problem solved. But then again, if someone has been fighting so long to allow fair usage of Internet browsers in Microsoft Windows (in Europe Microsoft is supposed to show the screen to choose one of the alternative browsers at the first use), why shouldn’t we do the same with Symbian? All the necessary applications should be built in, but with possibility of replacing them with our favorites (this also applies to the contact list, web browser, calendar, etc.).*

A resume of interesting ideas seen this day:

Idea 1: Make my email as easy and as intuitive as in Blackberry (there are so many solutions: default messages application, Nokia email from http://email.nokia.com/, custom clients like Gmail Java application, Mail for Exchange, but I cannot say I stayed with one of them because it fulfilled my needs)

Idea 2: Allow for the after-Ovi-store payments (as a framework for the application)

Idea 3: Use phone as GPS, and introduce the toll device built-in!

Idea 4: Make my shopping list intelligent (count the days after we have to buy the same product: milk, bread, corn flakes, fish) and adaptable (scan the bar code and add it to a product list?)

Idea 5: More battery life (really, and something like 2 weeks at least; remember that we don’t wind up watches since at least the early 90’s…)

Idea 6: Give me back my profile scheduler!

Idea 7: Make my Internet connection stable and easy to set up (this applies to constant querying for the access point, especially in the add-on platforms like Java or WRT).

Conclusion that comes to me after this day is that ideas.symbian.org, although seems to be a gate to ground-breaking features of the future, rather shows where Symbian is these days. What I wrote here is just a fraction of the ideas already placed on the website, but maybe it will work as a therapy for the platform development. Because the first step in learning is to acknowledge and not stay in denial.

*Correction. There’s an option to change default applications in my Nokia 5800. It’s in the Settings>Phone>Application Settings > Default apps. But so far I couldn’t make use of it.

Maemo community visited Barcelona last weekend, giving us a chance to have a peek at the newest Nokia’s N900 device and also learn something about the software creation for this up and coming competitor on the mobile market.

The event lasted 3 days on 4-5-6 of December 2009. The first day was mostly dedicated to lectures and presentations Two following brought some more insight to the Maemo software creation, and even some real programming occurred.

Quim Gil – the event organizer – and Jose Luis Martinez – vice president for Nokia’s N-series – gave the first speaches presenting the N900 device to the public. Local community could definitely be pleased having these important members of the Nokia team working also for them. Many lectures were lead in Spanish. This definitely helped some of the local attendees with understanding the topic, but it didn’t end up without confusion. People coming from other countries were rather expecting the event to be covered English than in this “Espanglish” mixture, which it ended up. Finally Spanish/English speaking experts were available at the lab/hacking sessions.

The event consisted of parallel sessions for the software creation, documentation and localization. There were a few last-minute changes in the agenda, so I’m not sure if they all happened as planned, but there was a choice of the classes, and the amount of information that I managed to receive was just enough. Coming from the Symbian community, my main concern was to get introduced to the Qt programming, and start creating and deploying it also on the new Maemo devices.

Aleix Pol and Jesus Sanchez-Palencia introduced some new Qt APIs, and were then attending programmers individually at the hacking session. That was a really good experience to work with them, and even though Qt seems to be a well structured and easy-to-learn environment, their help was essential. If you want to try them yourself, it would be good to start with some examples.

Daniel Wilms from Nokia presented some new tools for cross-compilation, which will help creating software for the N900 and future Maemo devices even quicker, and easier. But the environment for the device emulation and software creation still needs a few hacks to set it up on the computer. If I started configuring the ‘scratchbox’ myself, I’d probably only get the scratchhead effect, as the installer still fails at some stages that are a mystery for the average user. At least the basic knowledge of the aptitude software management, and the batch shell in Linux comes handy then. Hopefully obstacles will disappear from the installing process, but it’s worth to give it a try anyway. If the installer from the Forum Nokia website fails, try to read some hints on the Maemo Documentation website.

Finally the best and the funniest lecture was given by Patricia Montenegro from OpenBossa. The topic of relations between graphic designers and developers seems to have a good comedic potential, and while presented attractively was a real hit on the conference. There are some videos from the previous presentations, but the one from the conference in Barcelona was way better somehow. To find more try to search for UI from a broken home: The relationship between developers and designers.

Thanks for the good time spent with the Maemo programmers and zealots at Barcelona (actually Cornella) Citilab!

Maemo community visited Barcelona last weekend, giving us a chance to have a peek at the newest Nokia’s N900 device and also learn something about the software creation for this up and coming competitor on the mobile market.

The event lasted 3 days on 4-5-6 of December 2009. The first day was mostly dedicated to lectures and presentations Two following brought some more insight to the Maemo software creation, and even some real programming occurred.

Quim Gil – the event organizer – and Jose Luis Martinez – vice president for Nokia’s N-series – gave the first speaches presenting the N900 device to the public. Local community could definitely be pleased having these important members of the Nokia team working also for them. Many lectures were lead in Spanish. This definitely helped some of the local attendees understanding the topic, but it didn’t end up without confusion. People coming from other parts of Europe were rather expecting the event to be covered English than in this “Espanglish” mixture, which it ended up. Finally Spanish/English speaking experts were available at the lab/hacking sessions.

The event consisted of parallel sessions for the software creation, documentation and localization. There were a few last-minute changes in the agenda, so I’m not sure if they all happened as planned, but there was a choice of the classes, and the amount of information that I managed to receive was just enough. Coming from the Symbian community, my main concern was to get introduced to the Qt programming, and start creating and deploying it also on the new Maemo devic