Android App Development INFO1-CE9705

The NYU SCPS catalog description is limited to 100 words:

Learn to write Android apps using the Eclipse application on a Mac or PC. An app is composed of Java objects plus a screen layout in the Extensible Markup Language. See how a Java “activity” object manipulates this XML to present a user interface containing buttons, sliders, and other controls. Draw text and graphics, respond to a touch or keystroke with a “listener” object, recognize a swipe or pinch, and perform simple animations. Create menus and dialogs, open an SQLite database, play background music with a “service” object, and let the components of different apps communicate with each other.

To see if this course is right for you, start looking at the entire content of the course. This content is free and online. To see approximately how much homework there will be in Summer 2014, see how much there was last time.

Prerequisite. You must know how to create a class of Java objects, including methods with arguments and a return value. You must know how to create a Java object and call its methods with arguments and return value. You must know how to create a subclass of a Java class.

I am hopeful that NYU SCPS will let me teach this course in Summer 2014, meeting once per week for ten Wednesday nights, June 11 to August 18, 6:30 to 9:30pm at 7 East 12th Street. (The Fourth of July is on a Friday this year, so it doesn’t affect us.) If SCPS decides to go ahead, they will put my name, the Wednesday dates, and the above course description in their online catalog.

Catch my full-day Android course at the Agile Conference in Las Vegas on Monday June 2, and at QCon at the Brooklyn Marriott on Tuesday, June 10. It’s a condensed version of the first third of INFO1-CE9705.

Contact me:

  1. Homework
  2. In-class examples: these constitute the course.
  3. Catalog entry, syllabus and grading policy, instructor, dates for Fall 2011 at NYU SCPS.
  4. Install everything you need to write an Android app: the Java JDK, Eclipse IDE, Android ADT Plugin, and AVD(s). You can use an Intel Macintosh, Windows PC, or Linux host.
  5. GitHub accounts for students and their most recent projects.
  6. Classroom at 7 East 12th Street, between Fifth Avenue and University Place.
  7. Developer’s Guide, Coding Style Standards.
  8. This course parallels the instructor’s iPhone courses, and, like them, will probably be expanded into two semesters.
  9. Wikipedia article on Android
  10. AppInventor for Android lets you create the visual interface for an app by dragging widgets out of a pallet and positioning them on the screen, like the iPhone Interface Builder. It also lets you write code by assembling jigsaw puzzle pieces, like Scratch.
  11. Java Mobile Study Group in New York City
  12. Google NYC Tech Talks.
  13. New York City Data Sets: restaurant inspection results, etc. Traffic cams. Census Bureau.
  14. Class photos

Fall 2011 Homework

  1. Tuesday, October 18, 2011: we did XML, Object, Project, and Debugging output in the in-class examples. Admire last semester’s class photo; I’ll post this semester’s here as soon as I get it. Read the syllabus and grading policy. See how much homework there was last semester. My email address is

    Install Eclipse, etc. After installing them, you should be able to run commands such as

    adb help
    in the Terminal window of your Mac or the Command Prompt widow of your PC.

    Look at the online Android documentation for the Java classes we mentioned in class: View and its subclasses TextView and LinearLayout. (There’s even a LinearLayout tutorial.) Look at the flowchart in the documentation for class Activity. Read the Hello, World document and take a peek at the AndroidManifest.xml documentation.

    Create a GitHub account. You’ll have to invent a username for yourself; on October 25th, you’ll tell me what it is. Install or set up the application git. Create a repository named INFO1-CE9705

    Nothing to hand in this week, but do the Project and its “Things to try”. (What is the command on a Windows PC to recursively list a directory and all the files and directories under it—the child, grandchild, and great-grandchild directories, etc.?) You can save your project as a zip file on your hard disk and re-create the project from the zip file. We’s going to have a two-minute presentation by a volunteer about dragging a view (e.g., an analog clock) from the pallets into the main.xml file.

  2. Tuesday, October 25, 2011: up to Listener in the in-class examples. The Macintosh find command I showed you in class was
    find / -type f -name .asserts -print 2> /dev/null
    I added pixel density to Debugging. I corrected the ApiDemos compilation instructions so that you don’t have to comment out all those @Override Java annotations. I fixed the errors in Listener, and added a second button.

    Here are the GitHub accounts (including mine). Please email me your loginname if I don’t have it yet.

    Explore ApiDemos. We’ll have a brief in-class presentation about some of the other sample apps, e.g., Lunar Lander.

    Write an app with one or more Buttons and TextViews. Make something happen when you press the button(s). The colors and dimensions should be stored in resource files; see exercise #12 in Project. The strings should be stored in a resource file; see exercise #8 in Listener.

  3. Tuesday, November 1, 2011: up to android:layout_weight in LinearLayout. Can you get a RatingBar to work in the Android Emulator without crashing the app? Will avenue.C give you the correct cross streets for Park Avenue South if you enter that avenue as the number 4? (Park Avenue South used to be called Fourth Avenue.) The animation lecture included Ken Perlin’s Fish Tales animation.

    To find the full pathname of the two .xml files plugged into an ArrayAdapter<String> on a Mac, give the following commands in the Terminal.,

    find / -type f -name simple_spinner_item.xml -print 2> /dev/null
    find / -type f -name simple_spinner_dropdown_item.xml -print 2> /dev/null

    Write (and upload to Github) an app with widgets, and a second thread to make something keep happening (a counter, a change of color, etc). Have the Java code create at least some of the widgets; call addView and maybe removeView. Can’t think of what to write? The coolest man who ever lived was Derek Flint. Create an app that Mr. Flint might carry in his pocket. (He had the first ringtone ever.)

  4. Tuesday, November 8, 2011: up to Manhattan, but we haven’t done the Current Transformation Matrix (CTM) yet. I added an exercise where you put the Manhattan coördinates into a resource file. Which of the two ways of drawing the red stripes of the Flag was simpler: without or with a translate?

    You already have a GitHub repository named INFO1-CE9705. Create another repository named November16 (uppercase N, digits 1 and 6). Create a project named November16 and upload it to the new repository. The project should have your own subclass of View with an onDraw method that draws graphics. Look at the other students’s projects.

  5. Tuesday, November 15, 2011: up to Animate in the in-class examples. I rewrote Pinch with a ScaleGestureDetector, and it got a lot simpler. Is there a simpler way to do Animate? How many seconds does onSingleTapConfirmed wait before it announces a single tap? Can we change this number of seconds? Does the android:gestureStrokeType="multiple" attribute of the GestureOverlayView actually allow us to recognize multiple-stroke views such as a plus sign?

    Create an emulator with an SD card as we did here. Explore the inside of your phone or emulator with adb shell. Can you push and pull a file?

    Write a project named November22 (not Nov22) with graphics and touch-sensitivity and upload it to your INFO1-CE9705 repository on GitHub. Macintosh people: Can you use this shellscript to download everyone’s project and install and uninstall them, one by one, in an Android emulator? You’ll have to change November16 to November22

  6. Tuesday, November 22, 2011: up to NonConfigurationInstance in the in-class examples.

    I removed the redundant creation of the array from Pearl and changed the parameters (mass, gravity, etc.) to static final fields of class Pearl. I put getRefreshRate into the exercises. (My Motorola XPRT MB612 has a refresh rate of 68 per second.)

    But here’s what I’d really like to do. iPhone has a way of calling a method with each hardware refresh of the screen; see the CADisplayLink in Pong. If the frameInterval in the view controller is 1 (which it is), then the method move: in class View will be called each time the hardware refreshes the screen. If the frameInterval is 2, the method move: will be called every other time the hardware refreshes the screen. If frameInterval is 3, move: will be called every third time the hardware refreshes the screen. Is there anything like this in Android, which will let us synchronize a method call with a hardware refresh?

    Why does Html5 believe that the window is 320 × 240? Can we fix this with an HTML meta tag, maybe something like
    <meta name = "viewport" content = "width = device-width">

    Rooting Android 2.2.2 on Motorola XPRT cell phone, with pleasant, new-agey background music. You have to Download Motorola 5.2.0 Driver with MotoHelper and download SuperOneClock from Thanks, Mike.

  7. Tuesday, November 29, 2011: up to AsyncTask in the in-class examples. The TimePicker in the TimePickerDialog example now knows about 12- and 24-hour format. The onClick method of the DialogInterface.OnClickListener in the AlertDialog example now prints the correct verdict about the meaning of life.

    How about Leonardo da Vinci’s The Last Supper—is that the most famous landscape-orientation painting of all time?

    Write a project named December6 (not Dec6) with at least one dialog and upload it to your INFO1-CE9705 repository on GitHub.

    On December 6, we’ll have a report about the JavaScript framework Sencha Touch. Home page. Wikipedia article. Tutorial. PhoneGap.

  8. Tuesday, December 6, 2011: up to Result in the in-class examples. Write a project named December13 with a menu (options menu and/or context menu) that does something with an Intent. On December 13, we’ll have a report about talking to the emulator using telnet.

    Observe that the spinner in ApiDemos/App/Menu/Inflate from XML is broken in Android ≥3.0, SDK ≥ 11. The spinner is stuck at “Title only”. Read the source code in

    Sencha Touch demos: they will work properly only on a mobile browser (though they work okish in Chrome). Here is probably the best one. These are web pages so you can access the source with right click→show source. Also they are packed with the Sencha SDK Download.

    Breaking news (December 7): Apparently this technology is better than Sencha Touch. Where Sencha only gives you the front end, Phone Gap allows you to access native methods. See features.

  9. Tuesday, December 13, 2011: up to Cursor. You’ll want to look at the deprecated way of making the Cursor in ApiDemos/Views/Lists/02. Cursor (People) ( with Contacts.CONTENT_URI instead of ContactsContract.Contacts.CONTENT_URI.

    Write (and upload to GitHub) a project named December20 that does something interesting, e.g., involving intents, cursors, tabs, gridviews, galleries, etc. Fill out and return the course evaluations that NYU will email you; maybe you’ll win the $500 raffle. Next week: SQLite, GPS, and Google maps.

    We also did Busybox. I installed Busybox into my Android Emulator; what do I have to do to install it into my Motorola MB612 phone? When I tried to make the directory /data/busybox on the phone, mkdir said “Permission denied”.

  10. Tuesday, December 20, 2011:

Summer 2011 Homework

Please bring a cellphone to the first class to take the class photo.

  1. Tuesday, May 31, 2011: we did XML and Project in the in-class examples, except that we didn’t talk about the Debug and DDMS perspectives in Project. Admire the class photo; next week, we’ll make it touch-sensitive. Read the syllabus and grading policy. See how much homework there was last semester. My email address is

    Install Eclipse, etc. After installing them, can you run the command

    adb help
    in the Terminal window of your Mac or the Command Prompt widow of your PC?

    You created an AVD (a virtual device in the emulator) by pulling down the Eclipse Window menu and selecting Android SDK and AVD Manager. If you find the 3.1 tablet AVD too weird or too sluggish, you can make a more familiar 2.3.3 telephone AVD. Then when you create a project, specify 2.3.3 for the project’s Build Target.

    Look at the documentation for the Java classes we mentioned in class: View and its subclasses TextView and LinearLayout. Look at the flowchart in the documentation for class Activity. Read the Hello, World document and take a peek at the AndroidManifest.xml documentation.

    NYU has created accounts for almost everyone in the class. Get your loginname (same as your NYU NetID) and secret password, if you don’t already have them, for our Solaris Unix server If you couldn’t get a secret password from, contact the accounts office. One way to do this is by calling (212) 998-3333 option 1. Make it clear to the accounts office that you are trying to get a password for, not for Blackboard. (They think everyone is a Blackboard user.)

    Nothing to hand in this week, but practice saving your project as a zip file and re-creating the project from the zip file. For example, here is the file I created in class on May 31 at 9:30 p.m. Research projects: can you drag a view (e.g., an analog clock) from the pallets into the main.xml file? How can we upload a zip file to GitHub so we can see each other’s homework?

  2. Tuesday, June 7, 2011: up to ApiDemos in the in-class examples, except that we haven’t done subclass yet. (We will need subclassing in order to create an implementation of the interface View.OnClickListener.)

    I’m soliciting two-minute in-class oral reports on the following topics. Can we create a more elaborate piece of Toast? Besides ApiDemos, which sample apps would be educational and entertaining to play with (e.g., LunarLander)? How can we remember the sequence v, d, i, w, e, s? Very Dark Icebergs… To see the version of Android that is running on a phone, Settings → About phone → Android version. Does the Android version number determine the SDK version?

    Explore ApiDemos. For example, go to Views/Buttons. Then go to the Package Explorer in the Java Perspective of Eclipse and look at the files src/ and res/layout/buttons_1.xml.

    Write an app that displays text by means of a Toast, a TextView or Log.d. See debugging output. Save the app as a .zip file. Upload the .zip file to GitHub.

    Charles Shen has kindly provided the following instructions for GitHub.

    1. Go to Click the big blue button “Plans, Pricing and Signup”. Click the “Create a free account” button on the right side of the “$0 Free for open source” option on top to create an account.
    2. Once you have an account, login using your username and password. You will see four big boxes: “Set Up Git”, “Create A Repository”, “Fork a Repository”, “Be social”. We only need to deal with the first two at this stage.
    3. Click “Set Up Git”, and follow all the instructions on the page (which may be different depending on your OS) to set it up.
    4. Once Git has been set up, click “Create a repository”. Again follow all the instructions on the page. Now assuming you have created a project with the same name as in the instruction page, which is stored in the directory ~/Hello-World. In order to upload your homework file, e.g., at your home directory to GitHub, execute the following commands:
      $ mv ~/Hello-World
      $ cd ~/Hello-World
      $ git add
      $ git commit -m 'added'
      $ git remote add origin
      $ git push origin master
      (Use your real username for the “yourusername” parameter)

    As an example, I have uploaded a zip file on GitHub using my Mac. If you go to and search for cs3212, you will find one result cs3212 in the “Users” field. Click on it, you will find a public repository called HelloWorld, click on it and you can then download the file.

  3. Tuesday, June 14, 2011: up to the check box in Widgets. Here are the Github logins. Looking forward to an oral report about Android Styles and Themes.

    The coolest man who ever lived was Derek Flint. (Here’s his ringtone.) Design a pocket device for Mr. Flint with lots of buttons and/or other widgets (kilotons, megatons, Moscow, Peking, London). Or make any other app with lots of buttons. Each widget should respond in some way, e.g., with a piece of toast.

  4. Tuesday, June 21, 2011: up to TimePickerDialog in the in-class examples. See the Robert Kennedy example I added to Programmatic. Write an app that has more than one thread and upload the .zip file to GitHub.

    Can the Time object in TimePicker know about DaylightSavings Time? Why can’t the Safari and Firefox on the instructor’s Mac go to

  5. Tuesday, June 28, 2011: up to Progress Dialog in the in-class examples. I updated the audio recorder example and it now runs on my T-Mobile G1 Android phone with SDK 3. Does it run on your phone?

    Write an app with one or more dialogs and upload it to GitHub. Audio recording and/or playback would be a plus. Am I missing anybody’s GitHub username?

  6. Tuesday, July 5, 2011: up to Options Menu in the in-class examples. Click on the tip of each nose in the class photo. Can you identify the four unidentified men?

    When I changed the style of the Progress Dialog from STYLE_HORIZONTAL to STYLE_SPINNER here, the spinner spun correctly every time I launched the dialog in my 2.3.3 Emulator. I added an exercise to Don’t Tread On Me.

    Write and app (and upload it to GitHub) with an options menu. Play with the other students’ apps and their most recent app.

  7. Tuesday, July 12, 2011: up to GridView in the in-class examples. No homework.
  8. Tuesday, July 19, 2011: up to Swipe in the in-class examples. Write (and upload to GitHub) an app that does one or more of the transformations translate, scale, rotate, and/or skew. You can undo a transformation with save and restore.
  9. Tuesday, July 26, 2011: up to Zipcode in the in-class examples. The gesture recognizer thinks a vertical line is an instruction to scroll; how can we prevent this?

    Write an app that is touch-sensitive or that does something with an sqlite database. Save it in a zip file named Upload into a GitHub repository named july26 (four lowecase letters, two digits). If everyone has the same filename and the same repository name for this homework, I’m hoping I can easily create a shellscript that will upload everyone’s project into Eclipse all at once, and even downgrade all the projects to sdk version 8.

  10. Tuesday, August 2, 2011:

Class photos

  1. Fall 2011 Section 1 (Tuesday)
  2. Summer 2011 Section 1 (Tuesday)
  3. Spring 2011 Section 1 (Wednesday)
  4. Fall 2010 Section 1 (Saturday)