Time for the next chapter of my blog series about demonstrating how Ubuntu is the best environment to write up “connected” or “cloud backend” Android Apps. As you might know, the Android SDK allows you to set up a sandboxed environment to develop Mobile apps in your desktop, using Juju you can do the same for Cloud apps.
To walk you through how to put these great development tools together, I set out to accomplish:
Proof that you can access a Juju local environment from the Android Emulatordone!
Using a few charms from the charm store plus a custom one, set up a MySQL database that can be exposed through a web service with simple commands/steps– done!
- Develop a TODO list android app
- Connect the android app and the webservice, so they talk to each other.
Today I am going to cover the bottom two bullet points in one go! For this post, I am going to assume that you know a bit of Android development. If you want a great source of introductory material check Lars Vogel’s website.
I have created a simple ToDo Android application that can store tasks into a local SQLite db and allows you to “Star” important items. The code for my Simple Todo app is hosted in Launchpad. I have written my application for Android 2.3, but you can use a later version.
Reading remote data from the MySQL server is confined to a small class that retrieves a JSON object and translates it into a TodoItem object. Equally , the server code that prints that content table into a JSON object is extremely simple. Beyond this, you can go crazy and implement a RESTfull API to sync the databases.
At the moment, I am just inserting Server side data into the Local database and making sure I don’t add duplicates.Here is a video that shows how easy is to work and test both environments:
The same environment should then work if you are running the Android application on an external phone. But that is another blog post 😉