Pulsion Software Development Blog

Software, Programming & Technology

Mobile application development: A view of the Android platform

0 comments

android image

With mobile application popularity on the rise, this is an area of development which more and more developers will be likely to look at. As has been widely documented, HTML5 can do amazing things, and may be an obvious choice for many when building a mobile application – particularly for companies/teams with a background in web development, where building rich HTML5 applications for mobile devices will be purely an extension of their existing skills. But there is also an argument for building a mobile application using Google’s native Android platform (using Java as the primary language) – this can provide a closer link between device hardware and an application, and enable the application to integrate better with system features, other applications on the device, and provide a faster, smoother, more integrated user experience. This excellent presentation from Google I/O 2011 is definitely worth a look, if you’re interested in more on the HTML5 vs native Android apps debate.

I’ve worked with predominantly Microsoft-based development platforms and languages for many years now, so when I had some spare time I started to play around with Android (based in Java), it was an interesting change – and made me realise how long it’d been since I used a Java-based IDE! So in this post I wanted to provide some pointers to .NET based developers who are looking to learn (or at least play around with) Android.

First off, as you may have already discovered, Google’s Android Developers website (http://developer.android.com) has a crazy amount of really useful information for any developer interested in learning about Android – including detailed info on what to download and install, a big bunch of detailed tutorials, articles, best practices, API documentation, and sample applications to try out – really, you need to check it out if you haven’t already. I also found TekPub’s course Introduction to Android Development excellent. The TekPub guys have also put the code they wrote for this series up on GitHub – it’s interesting to go back through previous versions in GitHub and see how the code evolved for their demo application. Finally, if you’re looking for a book you could do a lot worse than Hello, Android by Ed Burnette – the chapters are very self-contained, so you can pick and choose the bits you’re interested in – and it covers a broad range of topics. The demo code shown throughout the book is also available for download, which is good.

Google encourage developers to use the Eclipse IDE for developing Android applications – on top of that sits the Android Development Tools (ADT). Eclipse is a very different beast to Visual Studio – in some ways nicer (it’s certainly faster, that’s for sure) – but I inevitably found myself frustrated at simply not knowing how to do things I needed to in Eclipse (being so used to Visual Studio) – so here are some general Eclipse points to bear in mind if, like me, you’re too used to using Visual Studio:

  • Building:
    Unlike Visual Studio, Eclipse automatically compiles after every save (you can change this setting, of course, if you really wanted to, via Project -> Build Automatically).
  • Immediate Window:
    “Display” view is the equivalent of this in Eclipse
  • Perspectives:
    Eclipse has the idea of different perspectives (e.g. Java, JavaScript, Debug, and an Android specific one, DDMS) – this means you can customise your layout for different tasks – e.g. debugging, general development, etc. More flexible than the options Visual Studio provides for customising layouts.

And here are some Android specific development issues that may be worth a mention:

  • IP address for accessing localhost: I had created a REST based WCF service in .NET that I had hosted on my local machine in IIS, but couldn’t get the service URL to work from my Android app in the emulator – turns out you need to use the alias 10.0.2.2 to refer to localhost in Android.
  • Accessing file system on emulator
    Stumbled with this one a bit. Turns out it’s just Window -> Show View -> Other -> File Explorer. This allows you to copy files to and from the emulator (in my case, I needed to copy & delete SQLite DB files).
  • GUI editor for XML layout files:
    A GUI editor is supplied with the ADT plugin that allows you to graphically change an Android view XML layout file – but the editor has been a bit lacking, particularly for constructing lists (you had to build these purely in XML, since the editor gave you no graphical help). This has thankfully been addressed in a recent release, and the editor is now definitely better than before – but I’d still recommend creating your layout files directly in the XML view, simply because you’re guaranteed complete control. The 3rd party program DroidDraw is very good, worth checking out.
  • Using a WebView:
    Came across a strange issue with WebViews: if I created an XML layout file that just contained a webview element (ie – with no parent layout object like LinearLayout), it worked fine in the Google-based emulator, but fell on its face when trying on a Samsung Galaxy phone (or the Samsung Galaxy Tab emulator). If you wrap the WebView in a layout element, it works fine though.
  • Finally, some really obvious things:
    (You probably know these already if you’ve played with Android, but they’re easy to forget…)
    • LogCat view in Eclipse: An essential way to see information and error messages generated by the application on your device/emulator.
    • Debugging: Remember if you’re debugging on an actual device (as opposed to am emulator), make sure you set the android:debuggable attribute to true in your app’s manifest file.
    • Remember when you add a new activity to your application, to also add it to the manifest file
    • If your application connects to the internet (e.g. to connect to a REST service or a webpage), remember to explicitly add the permission “android.permission.INTERNET” to your manifest file.

To find out more about any of the Pulsion mobile application development projects please email us at info@pulsion.co.uk

Leave a Reply

Required fields are marked *.

*