"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects." (Robert A. Heinlein)

Friday 23 November 2012

Blog-Birthday Four

One more year of blogging passed. It has been a year a bit troubled by the shut down of my old provider (i.ph) and the passage to Blogspot. The platform change brought to an inevitable loss in visits but my will to blog my experiences is still the same. So thanks to all my visitors and ... Stay tuned!

Tuesday 13 November 2012

Android programming : Exploring sensors

Sensors are one of the the things that make mobile development different, and interesting, from the programming of our desktop computers. Modern mobile devices with their combined capabilities of communicating, imaging and sensing surrounding environment looks more like a pocket version of a artificial satellite than a desktop computer. This is why, after initial hello-worlding, the first thing I've been looking for in the 'net has been how to read sensors in an Android application. I got several examples like here, all showing how to read a single sensor. I decided so to make more interesting these basic examples in order to build a simple user interface able to discover and read available sensors on a device.

The user interface design

After reading about sensors on Android worked I refined my idea on how the user interface: a selector (also known as spinner) on the top filled with available sensors list, some details on the selected sensor just under the selector and sensors values updating on the bottom.
User interfaces (activities) layout is defined, in Android programming, trough a XML file. Eclipse Android development plug-in provides a handy graphical user interface to arrange activity layout. It worked for me well enough even if I went to manual XML editing a couple of times just to make things a little faster. Eclipse plug-in also provide a lot of useful warnings, to a beginner like me, like reminding not to place hard-coded strings in your interface. By the way here is, at last, my interface definition.