[A Juju adventure] Linking up with Android
July 24, 2012 4 Comments
In my previous entry, I argued that Ubuntu is possibly the best development environment to write connected android apps, thanks to Juju. Although using WordPress was possibly not a great example🙂 I still think that this idea has legs! Hence, I have decided to build an example project.
The example will mainly be a simple and plan ToDo list app for Android, that gets its items from a back-end MySQL server.
So here is my list of things to get done for this example project:
- Proof that you can access a Juju local environment from the Android Emulator
- Develop a TODO list android app
- 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
- Connect the android app and the webservice, so they talk to each other.
And as there is no time like the present, here is the first bullet point!
Accessing a Juju Local Environment from the Android Emulator
As I was working on my wordpress charm, the easiest thing for me to do was to access the local webserver set-up for the blog. I first installed the Android SDK, which turned out to be pretty easy to do by just following the instructions posted at http://developer.android.com/sdk/index.html . Apart of the sdk tools that download you the emulator, build tools and so on.. you can also choose to use Eclipse as your IDE. If you do this, you can then install an Android plug-in that is *very very* complete. Having had previous experience with Eclipse, I choose this root and unless you feel very strongly against it, I recommend that you do the same.
Once I had the SDK installed, I run the 2.2 emulator (because that happens to be the version in the spare Android phone that I plan to use later on) and open the local IP address of the WordPress service. That just worked fine.
Then I decided to create a sample android project and tried some code to do the same. I found that the following method within the main activity of the project was able to ping and then open in a browser window the wordpress app:
So in a nutshell, the first bullet point (and the easiest) of my list is completed!