Open main menu

CDOT Wiki β

Changes

BTC640/Mobile

2,298 bytes added, 11:47, 11 February 2012
no edit summary
= Lecture /Lab =
This week we'll be looking at how to develop for mobile devices. On a small screen there is little room for anything, thus presentation is king.
We will set up an Android development environment including an emulator, create a simple Android application, and a small webpage geared to mobile. You'll do the same stuff in the lab that I showed you in class.
== Android development environment ==
An Android Virtual Device is a virtual machine that runs Android, it's great for testing applications. You can normally create virtual machines with different Android versions but on Andora we only have the 2.3.3 SDK installed. You still can choose different screens and other hardware parameters.
We want to be able to test the app we create even if you don't have an Android phone, so we'll create an AVD.
* Open up the Android SDK and AVD Manager in Eclipse
* Create a new virtual device
* Give it a name (whatever you want), select a target (there's only one choice)
* This is important: '''Do not create a large SD Card'''. Since everything is in RAM you only have a few hundred megs of disk space, so even though a 16MB SD card is unrealistic, we won't need more than that for anything we'll be doing. If you create a much larger SD card you will simply run out of virtual disk space and everything will crash.
* Start your device, and wait for it to boot. You can play around in there, this is what an Android phone is like.
* Leave the emulator running, and go back to eclipse. You can close the SDK and AVD Manager now.
== Sample App == We're going to create an app that does almost nothing, but that should be good enough for one lecture and one lab. * Create a new Android project in Eclipse. Give it a name and a package name such as ca.senecacollege.yourlearnid You do not need a test project.* Have a look around, interesting parts are:** The src/ with the single Java file. This is all the source code your app has at this point.** XML files, which can be viewed using a pretty graphical viewer or a simple text/xml viewer by choosing the tab at the bottom after you double-click on the file in Eclipse.*** AndroidManifest.xml - information about your app, its platform and permission requirements.*** res/values/strings.xml is the collection of translatable strings, similar to a POT file. If you add a new string in your UI you should add it here.*** res/layout/main.xml is the XML definition of the current layout of your app. You can do quite a bit in here without knowing a lot about Android or even Java.*** Note that the R.java file under "gen" is automatically generated by the compiler from your xml files, don't be tempted to manually edit it.* Select your package in the package explorer, and click the green Run button. Run it as an Android application. This will compile your app and run it on your phone (if it's connected) or on the emulator (if it's running).* Go back to main.xml and make the app a login screen. Change the hello world text (using an existing or new @string resource) to "YourName's fancy app", add username/password textviews and fields, and a button. Make sure your new fields and button text are @string resources. = Lab submission =
This is a marked lab. Please submit it using Moodle (Lab5).
 
In the lab you'll be doing some the same stuff that I've shown in class. You can use the live cd or create a more permanent Android development environment on your own machine. No point making it on the lab machines, unless you only want to practice the setup.
Submit a zip file (or another compressed format) of your project and a screenshot of the emulator running your code.