Mobile Application Development with Android¶
Mobile applications backed by cloud-based RESTful services have emerged as the primary face of computing in terms of massive consumer participation. Jason Christensen described this system architecture in his OOPSLA 2009 presentation. Therefore, not only do we find it important to cover this system architecture in the curriculum, but we also see this architecture as a very effective context for teaching various important computer science topics:
- (real-world) software architecture
dependency inversion principle (DIP)
model-view-adapter architectural pattern (MVA)
testability
etc.
- concurrent, parallel, and distributed computing topics (PDC/TCPP/EduPar)
events
timers (one-shot and recurring)
background threads
offloading tasks to the cloud
- embedded/resource-conscious computing
limitations of the device
capabilities of the device (numerous sensors)
Konstantin drew the inspiration to use Android instead of Swing as a context for teaching these topics from the mobile computing session at SIGCSE 2012 in Raleigh.
Furthermore, we have found the cost of switching from, say, Java Swing to Android minimal. Besides, Android matters in the real world: it is a widely used technology, and mobile app development skills are in increasing demand.
While our overall goals are similar to those of the Sofia framework project, we discuss here a language-based approach but are planning to enhance the practice of Android development in Scala through additional support classes.
As mentioned above, current and future focus has been on these courses:
COMP 313/413: Intermediate Object-Oriented Development (focusing on software design and architecture), using Java with Android since fall 2012, considering the addition of Scala down the road
COMP 373/473: Advanced Object-Oriented Development, using Scala since spring 2010, planning to add Android in spring 2014
Tools¶
There are two sbt plugins for developing Android:
The rapidly evolving topic of developing Android apps in Scala is the subject of this discussion forum:
After some experimentation, we have found pfn’s plugin to be easier to use and have adopted it for our Scala-based Android development.
Examples¶
The learning objectives of each example are stated in the example’s readme.
Lab Assignment¶
- Format
Pair project
- Time
10 minutes
- Deliverable
An enhancement of this clickcounter app that addresses at least one following additional functional requirements:
New user story: a max (^) button as the analogous dual to the reset (0) button.
Retaining application state during rotation (see here to find out how to rotate the emulator).
- Nonfunctional requirements
You should update the tests and the rest of the existing code accordingly.
You should implement the
onSaveInstanceState
andonRestoreInstanceState
application lifecycle methods (see for details. The system passes this method a Bundle in which you can save state information about the activity as name-value pairs, using methods such asputString()
andputInt()
.