Android development – NFC / REST / Android Studio

Since the last post, I submitted a first draft literature review. It wasn’t particularly long and it probably still meanders a bit too much. Since submitting, I have continued to try to narrow my focus. Whereas before I intended to keep the technological augmentation of the museum to a minimum, with electronic id tagging of objects being as far as that went, I have now explored more advanced augmentation with Raspberry Pi and Arduino to the fore, both of which individually or combined provide access to a wide range of sensors and actuators that can be used to build interactive exhibits, for example.

However, the original plan to explore RFID and NFC on Android-enabled mobile devices is continuing. While I have Java experience, I have no Android experience. The Android SDK provides a whole new framework to learn with various files in various locations that you need to become familiar with. I don’t find it nearly as intuitive as getting to grips with a web MVC framework, as I have done recently with Laravel for PHP and Spring MVC for Java. But I am persevering and making slow progress.

There are a number of tools available for Android development. The most commonly-used is Android Developer Tools (ADT) plugin for Eclipse. My first Android adventures began with ADT. However, when I tried to get it working with a package / build manager – specifically Maven – I ran into all kinds of problems. I also tried the new Android Studio, which is still far from stable. Android Studio is built on the IntelliJ platform, which competes with Eclipse. An advantage it does have over ADT/Eclipse is Gradle integration. Gradle provides a package manager to download dependencies, much like you would inside a Project Object Model file (pom.xml) in Maven. I’ve only just started to feel comfortable with Maven and now I have yet another Ant-style tool to learn.

While obviously less stable than the more mature Eclipse + ADT, I am going to persevere with Android Studio. I get the feeling that Google is putting its weight behind it, offering integration with various Google cloud services, such as App Engine, as well as more specific Android features. Gradle also seems to simplify package and build management in comparison to Maven, for example.

In addition, I have been looking at the Spring for Android project. The Spring Framework for Java provides a means of developing applications that provides layers of abstraction for various complex technologies, or technologies with a lot of configuration overhead or that require lots of code to check for errors, etc. For these technologies, Spring simplifies configuration and through something called Aspect Oriented Programming (AOP), reduces the amount of “boilerplate” code needed (i.e. repetitive code that is error prone due to bad habits like copying and pasting). There is also a Spring Mobile project which is not Android specific and instead is for developing cross-platform web-based solutions using Spring MVC. That sounds great on the face of it, but I want to develop a native Android app to ensure I can get the maximum out of the platform and have proper access to hardware features, such as NFC.

I hit a few issues when trying to build even the Hello World project when trying to include Spring libraries. I found a solution here: http://forum.spring.io/forum/spring-projects/android/743289-importing-android-spring-with-gradle-cause-error-mutiple-dex-files

What have I achieved thus far with Android? I added code to read an RF tag. The test tag I used was taken from the plastic bag covering exam papers I had to correct. It contained some simple text data: “DATA8002 – 24012”. That’s the module code and a unique id number identifying the teaching instance of the module. For test purposes, this is all I need. However, as time goes on, I will need to get some fresh RF tags and use an NFC writer to add my own id data. In addition, I will need to get my hands on some more advanced NFC cards so that I can put some user data on there, most likely encrypted.

I was able to test that the device I was using – a Google Nexus 7 tablet – was able to read the data from the tag. The NFC TagInfo Android app allowed me to verify that. Then I found a useful Android NFC tutorial that saved some time: http://code.tutsplus.com/tutorials/reading-nfc-tags-with-android–mobile-17278

The end result isn’t Earth-shattering. I was able to develop a simple app that could intercept NFC tag reads and display data on the screen. The next post will detail how I managed to connect to a collections management system, Omeka, using the REST protocol (thanks to Spring Android) to retrieve Dublin Core-compliant object/item metadata in JSON format for display on my tablet.

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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