Pages

Saturday, 15 January 2011

Exploring Andoid

Now when I have two droids, a phone and a MP3 player, I spent some effort to play with Android development the other day. I am in deep need of a audio book player that will not mix my huge amount of audio books with the music, and that will not have easily accessible functions like next track as I only use them unintentionally (frustration!). Android comes with some nice design features that I think have been "concepts in mind" or "slideware" since the 90:s but Google have implemented just nice.

I am talking about the Intents and Activities.

From my point of view (mainly Qt development in C++ when it comes to end user applications) I compare the Activity with a full screen dialog with a special purpose. This is not really the same as an ordinary main window; activities is expected to come with an intention - the Intents. The intents describes the intention of an Activity.

So far nothing special. I design my main window as an activity and next thing is to open an audio file from the book. Now I need to start another activity where I can browse files. At the first glans I though this to be an easy task. Then I stumbled on the Intent and things got complicated. After some reading everything turned impressed instead.

Here goes:
The framework is built so when I need to have something done I find the corresponding Intent (i.e. PickFile in my case) and ask for an activity that will provide me with that intended function. The system will try to match this and if there are alternatives, the user will be asked to chose. The proposed way to make sure I have my own Activity started is to create an unique Intent identifier and fire it of.

So, why is this really cool?
Take a look at http://www.openintents.org/. There you have a database of intents and can download or purchase the module supplying the activity. This means that using Intents you can use and resue, not only open source code by copying it into you application, but you can use closed source modules as well.

Experimenting with Intents
and Activities as Use Cases
I like to express my self using UML or other graphical notations. I started to experiment how to model my Audiobook player (named Narrator and have a yet empty project page at http://gitorious.org/narrator ) using intents. The figure shows how I ended up modelling the Intents as existing and reusable Use Cases. This is the point when I really start liking the concept; it really enables software reuse rather than code reuse. Use Case reuse is on a higher level than code reuse and I think that it is on this level reuse must be made if to make sense. This way I will be reasonable flexible with the requirements around the use case Open File thus allow for alternative solutions.

No comments:

Post a Comment