Android currency converter using PureMVC

Android currency converter using PureMVC

I'm working on an Android Froyo application in the goal of better learn Android development while developing a real Android application. It uses PureMVC for Java. I initially have planned to make it public here only when the application would have been pushed on the Android Market. But when I occasionally talk about this project here on my blog and on the PureMVC forums, some folks were really interested and ask me to give some help on how I achieved my PureMVC app development with Android. So today I decided to publish the application in its alpha stage even if it's still not ready.

The application is a currency converter that uses a webservice hosted on my website for several years that deliver currencies rate for 40 currencies with a daily update. Currencies rate are obtained from the European Central Bank. I recently have worked a on the webservice (PHP 5/ MySQL 5) to deliver currencies name in all existing languages supported by Android. I used a Java project based on the IBM International Components for Unicode project to fill the database with the I18N informations I needed.

The Android application itself uses threads, multiple activities, PreferenceActivity, SQLite local storage, Json and a call to a webservice and has unit tests associated to it. So this is what I think to be a good example to start with Android and PureMVC. I will commit its sources to the PureMVC website when it will be committed to the Android market as well.

My choice was to use the PureMVC multicore version with each PureMVC core controlling an Android Activity instance.

When an Activity is created I simply take care to remove any core existing with the same name because the Android system could decide to remove silently the Activity associated to a core to free up some memory when needed. The core could legitimately be there, the getInstance() will return it, but the Activity associated to it could have been garbaged. This could lead in some stupid situation. There are many ways (and best) to achieve the same result, but this one take only one line of code. This made, I think the use of PureMVC with Android is a really neat way to manage multiple Android activities.

The next step would be to test if there's a way to make activities communicate using PureMVC pipes without derogating to the Android recommended way to make activities communicate. I think this would be possible. But probably by extending the Pipes extension.

Another part of my planned work is to give a better UI design to the application. As you will see I use only a rough design integration to test UI for the moment.

Anyway you can :

10 thoughts on “Android currency converter using PureMVC

  1. This is pretty interesting stuff, Frederic. I look forward to seeing it run and diving farther into the finished code. I’m wanting to get into Android as well as many other PureMVC developers, so on everyone’s behalf, thanks for forging into these waters.

    -=Cliff>

  2. Hi Mark, I didn’t had any time for this actually.

    If your application isn’t too large you can use “startActivityForResult” and use result sent by your Activity when it closes. In fact, my idea wasn’t to allow Activities to communicate directly as this isn’t a good Android practice at all, but instead to wrap Intent result sent by this method and send them to Pipes to make the Application more PureMVC compatible.

  3. thanks for the tip. i’ll see what i can do. and thank you so much for posting your work and for responding!

  4. VI are you using the demo code I made for your app? Can you share it anyway if you are using PureMVC or if the code is interesting anyhow?

  5. What need is to complex code? Android SDK offers you fine MVC/MVP/MVVM framework. I use the activities as controllers/presenters/view-models, the views as views and services, content providers or self-made classes as models. And I always get excellent MVC project. For example, if I rewrite your currency converter into Android-supposed architecture, I will use 2 times less classes than you.

  6. Yep QuickNick, we discussed it on the PureMVC forums and we’re all agree that programming Android using PureMVC is not as necessary as using it programming basic Java. This was mainly a test for me and others. The result was the one you noted, so the goal for me is achieved.

    This said on a really complex Android app I would check again for some home made PureMVC solution to let Activities communicate, this is really to cumbersome as is.

  7. Thanks for comment. Would you give me please the link to this discussion and discussion about use PureMVC for iOS?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

  Am Not Spammer

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>