This week I’ve been working on a simple Android application. A customer of mine had the requirement for an ‘app’, but wanted to keep as much logic as possible on the mobile-web version of his web application, which is written in JQuery Mobile.
I downloaded Eclipse and installed the Android plug-in, and was amazed at how quickly I was up and running. Eclipse is a little weird on Windows, in that it doesn’t get installed, and the concept of ‘work benches’ is a bit different than I’m used to as a Windows developer– but it wasn’t too difficult to get going…
I created a simple application with a web view, and was able to access the mobile website through it fairly easily. I over-rode the back button and passed it to the web view, and I was off and rolling. The next part was a little more complex, however… I needed to implement all of this logic(potentially more in the future), in a library that I could easily inherit in ‘instances’ of this app, per se– so each one could be branded individually… This was a bit more difficult, but I was able to figure it out eventually… The biggest roadblock, was that Android seems to build all the resources together from libraries and the current app– so I had a main.xml layout in both apps, and it was discarding it from my library in favor of the one in my instanced app… This gave me errors about not being able to find the resource ID of the web view in the library code… Once I figured that out, I was on my way… I was also able to use this to my advantage, in that I could easily put any customizable parameters in my instanced app in the strings.xml file– and the library could access these resources!